<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><script>(()=>{const e=navigator.serviceWorker;e?e.register("/sw.js").then((async e=>{console.log("SWPP 注册成功");try{await e.periodicSync.register("update",{minInterval:864e5})}catch(e){console.log("Periodic Sync 注册失败",e)}})).catch((e=>console.error("SWPP 注册失败",e))):console.warn("当前浏览器不支持 SW")})()</script><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><title>PaddleYOLO训练自己的数据集 | LiuShen's Blog</title><meta name="author" content="LiuShen"><meta name="copyright" content="LiuShen"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="robots" content="index, follow"><meta name="description" content="近期一直在研究毕业设计，在其中，我涉及到了PaddleYOLO的训练和部署，在网上的教程较少，经过不断努力，我也算是跑出来了，所以在这里分享出来做个记录，防止下次使用又忘记了怎么搞。"><meta property="og:type" content="article"><meta property="og:title" content="PaddleYOLO训练自己的数据集"><meta property="og:url" content="https://blog.liushen.fun/posts/4bb33804/"><meta property="og:site_name" content="LiuShen's Blog"><meta property="og:description" content="近期一直在研究毕业设计，在其中，我涉及到了PaddleYOLO的训练和部署，在网上的教程较少，经过不断努力，我也算是跑出来了，所以在这里分享出来做个记录，防止下次使用又忘记了怎么搞。"><meta property="og:locale" content="zh_CN"><meta property="og:image" content="https://p.liiiu.cn/i/2025/04/08/67f49876a62e5.webp"><meta property="article:published_time" content="2025-04-08T07:27:21.000Z"><meta property="article:modified_time" content="2025-04-08T07:28:21.000Z"><meta property="article:author" content="LiuShen"><meta property="article:tag" content="学习笔记"><meta property="article:tag" content="机器学习"><meta property="article:tag" content="神经网络"><meta name="twitter:card" content="summary"><meta name="twitter:image" content="https://p.liiiu.cn/i/2025/04/08/67f49876a62e5.webp"><link rel="shortcut icon" href="/favicon.ico"><link rel="canonical" href="https://blog.liushen.fun/posts/4bb33804/"><link rel="preconnect" href="https://jsd.liiiu.cn"><meta name="baidu-site-verification" content="codeva-i2bF9bXDJs"><meta name="sogou_site_verification" content="1rIjtK6RhE"><meta name="360-site-verification" content="b9a9f96ae38a1932a326f8ba255cc74b"><meta name="msvalidate.01" content="F7C246820EB04DD140494C98F93A97C7"><meta name="google-site-verification" content="VH3ZE6m42MZDqpTY2tD-XoxDt9iUj2HoiC3W2neB7F4"><link rel="manifest" href="/manifest.json"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/config/img/pwa/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/config/img/pwa/favicon-16x16.png"><link rel="mask-icon" href="/config/img/pwa/favicon-mask.svg" color="#5bbad5"><link rel="stylesheet" href="/css/index.css?v=5.0.0"><link rel="stylesheet" href="/css/custom.css?v=5.0.0"><link rel="stylesheet" href="https://jsd.liiiu.cn/npm/@fortawesome/fontawesome-free@6.7.2/css/all.min.css"><link rel="stylesheet" href="https://jsd.liiiu.cn/npm/@fancyapps/ui@5.0.36/dist/fancybox/fancybox.min.css" media="print" onload='this.media="all"'><script>(()=>{const e={set:(e,t,o)=>{if(!o)return;const n=Date.now()+864e5*o;localStorage.setItem(e,JSON.stringify({value:t,expiry:n}))},get:e=>{const t=localStorage.getItem(e);if(!t)return;const{value:o,expiry:n}=JSON.parse(t);if(!(Date.now()>n))return o;localStorage.removeItem(e)}};window.btf={saveToLocal:e,getScript:(e,t={})=>new Promise(((o,n)=>{const a=document.createElement("script");a.src=e,a.async=!0,Object.entries(t).forEach((([e,t])=>a.setAttribute(e,t))),a.onload=a.onreadystatechange=()=>{a.readyState&&!/loaded|complete/.test(a.readyState)||o()},a.onerror=n,document.head.appendChild(a)})),getCSS:(e,t)=>new Promise(((o,n)=>{const a=document.createElement("link");a.rel="stylesheet",a.href=e,t&&(a.id=t),a.onload=a.onreadystatechange=()=>{a.readyState&&!/loaded|complete/.test(a.readyState)||o()},a.onerror=n,document.head.appendChild(a)})),addGlobalFn:(e,t,o=!1,n=window)=>{const a=n.globalFn||{};a[e]=a[e]||{},o&&a[e][o]||(a[e][o||Object.keys(a[e]).length]=t,n.globalFn=a)}};const t=()=>{document.documentElement.setAttribute("data-theme","dark"),null!==document.querySelector('meta[name="theme-color"]')&&document.querySelector('meta[name="theme-color"]').setAttribute("content","#0d0d0d")},o=()=>{document.documentElement.setAttribute("data-theme","light"),null!==document.querySelector('meta[name="theme-color"]')&&document.querySelector('meta[name="theme-color"]').setAttribute("content","#ffffff")};btf.activateDarkMode=t,btf.activateLightMode=o;const n=e.get("theme"),a=(new Date).getHours();void 0===n?a<=6||a>=18?t():o():"light"===n?o():t();const r=e.get("aside-status");void 0!==r&&document.documentElement.classList.toggle("hide-aside","hide"===r);/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)&&document.documentElement.classList.add("apple")})()</script><script>const GLOBAL_CONFIG={root:"/",algolia:{appId:"7IX3UBC6JW",apiKey:"4ac2846352e499675081f1277fb961c1",indexName:"My Blog",hitsPerPage:6,languages:{input_placeholder:"搜索全站文章",hits_empty:"未找到符合您查询的内容：${query}",hits_stats:"找到 ${hits} 条结果，耗时 ${time} 毫秒"}},localSearch:void 0,translate:{defaultEncoding:2,translateDelay:0,msgToTraditionalChinese:"繁",msgToSimplifiedChinese:"簡"},noticeOutdate:{limitDay:365,position:"top",messagePrev:"本篇文章从发布到现在已经隔了",messageNext:"天了，里面的内容可能过期了，你要自己甄别一下哟👉👈"},highlight:{plugin:"highlight.js",highlightCopy:!0,highlightLang:!0,highlightHeightLimit:400,highlightFullpage:!1,highlightMacStyle:!0},copy:{success:"😋复制啦！请注意版权信息呀！",error:"😪呜呜，复制失败了！",noSupport:"🤐浏览器不支持呢，你用的啥玩意？"},relativeDate:{homepage:!1,post:!1},runtime:"天",dateSuffix:{just:"刚刚",min:"分钟前",hour:"小时前",day:"天前",month:"个月前"},copyright:{limitCount:1e3,languages:{author:"作者: LiuShen",link:"链接: ",source:"来源: LiuShen's Blog",info:"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},lightbox:"fancybox",Snackbar:{chs_to_cht:"已切换为繁体中文",cht_to_chs:"已切换为简体中文",day_to_night:"已切换为深色模式",night_to_day:"已切换为浅色模式",bgLight:"rgba(255, 255, 255, 0.509)",bgDark:"rgba(48, 48, 48, 0.509)",position:"top-right"},infinitegrid:{js:"https://jsd.liiiu.cn/npm/@egjs/infinitegrid@4.12.0/dist/infinitegrid.min.js",buttonText:"加载更多"},isPhotoFigcaption:!0,islazyload:!0,isAnchor:!1,percent:{toc:!0,rightside:!1},autoDarkmode:!1}</script><script id="config-diff">var GLOBAL_CONFIG_SITE={title:"PaddleYOLO训练自己的数据集",isPost:!0,isHome:!1,isHighlightShrink:void 0,isToc:!0,postUpdate:"2025-04-08 15:28:21"}</script><link rel="stylesheet" href="https://jsd.liiiu.cn/gh/willow-god/Sharding-fonts/Yozai-Medium/result.min.css"><link rel="stylesheet" href="/config/memos/memos.css"><script defer src="/sw-dom.js"></script><link rel="stylesheet" href="https://jsd.liiiu.cn/npm/swiper@11.1.14/swiper-bundle.min.css" media="print" onload='this.media="all"'><link rel="stylesheet" href="/config/swiper/swiperstyle.css" media="print" onload='this.media="all"'><meta name="generator" content="Hexo 7.3.0"><link rel="alternate" href="/atom.xml" title="LiuShen's Blog" type="application/atom+xml"></head><body><div class="float-box right top"></div><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><img class="load-image" src="" data-lazy-src="/config/img/preloader.gif" alt=""></div><script async>(()=>{const e=document.getElementById("loading-box"),d=document.body,t=()=>{d.style.overflow="",e.classList.add("loaded")},n=()=>{d.style.overflow="hidden",e.classList.remove("loaded")};n();let o=!1;window.addEventListener("load",(()=>{o||(t(),o=!0)})),setTimeout((()=>{o||(t(),o=!0)}),5e3),window.addEventListener("load",(()=>{t()})),setTimeout((function(){t()}),3e3),document.getElementById("loading-box").addEventListener("click",(()=>{t()})),document.addEventListener("pjax:send",(()=>{n()})),document.addEventListener("pjax:complete",(()=>{t()}))})()</script><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="add-menu-container"><div id="travellings"><a class="site-page" href="https://www.travellings.cn/go.html" title="友链接力-随机开往" target="_blank" rel="noopener nofollow"><i class="fa-solid fa-bus fa-fw"></i></a></div><div id="ten-years"><a class="site-page" href="https://foreverblog.cn/go.html" title="友链接力-十年之约" target="_blank" rel="noopener nofollow"><i class="fa-brands fa-nfc-symbol fa-fw"></i></a></div></div><div class="is-center" id="sidebar-avatar"><div class="avatar-img is-center"><img class="mood-icon" src="" data-lazy-src="https://p.liiiu.cn/i/2025/03/14/67d301461a24a.webp" alt="🤤" onerror='this.onerror=null,this.src="/img/friend_404.gif"'><img src="" data-lazy-src="https://p.liiiu.cn/i/2025/03/13/67d2fc82d329c.webp" onerror='this.onerror=null,this.src="/img/friend_404.gif"' alt="avatar"></div><div class="author-info__name">LiuShen</div></div><div class="site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">72</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">98</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">3</div></a></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/willow-god"><i class="fab fa-github"></i><span>Follow Me 🛫</span></a><div class="menus_items visible"><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fas fa-home"></i> <span>导航</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.liushen.fun/"><i class="fa-fw fa-solid fa-house-flag"></i> <span>个人主页</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://xc.liushen.fun/"><i class="fa-fw fa fa-camera-retro"></i> <span>个人相册</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa fa-graduation-cap"></i> <span>整理</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i> <span>时光卷轴</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i> <span>文章标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i> <span>文章分类</span></a></li><li><a class="site-page child" href="/charts/"><i class="fa-fw fa-solid fa-chart-pie"></i> <span>文章通览</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa-solid fa-user-group"></i> <span>友人</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/link/"><i class="fa-fw fas fa-link"></i> <span>友链展示</span></a></li><li><a class="site-page child" href="/addlink/"><i class="fa-fw fa fa-at"></i> <span>友链申请</span></a></li><li><a class="site-page child" href="/fcircle/"><i class="fa-fw fa-solid fa-circle-nodes"></i> <span>朋友动态</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa fa-paper-plane"></i> <span>留言</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/comment/"><i class="fa-fw fa-solid fa-chalkboard"></i> <span>留言白板</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://mm.liushen.fun/"><i class="fa-fw fa-solid fa-pen-nib"></i> <span>提笔摘星</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa-solid fa-stethoscope"></i> <span>分享</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://gist.liushen.fun/"><i class="fa-fw fa-solid fa-code"></i> <span>代码片段</span></a></li><li><a class="site-page child" href="/subscribe/"><i class="fa-fw fa-solid fa-rss"></i> <span>订阅本站</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://pan.liushen.fun/"><i class="fa-fw fa-solid fa-laptop-file"></i> <span>清羽云盘</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa fa-list"></i> <span>关于</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/about/"><i class="fa-fw fa fa-address-card"></i> <span>站长资料</span></a></li><li><a class="site-page child" href="/shuoshuo/"><i class="fa-fw fa fa-commenting"></i> <span>日常说说</span></a></li><li><a class="site-page child" href="/devices/"><i class="fa-fw fa-solid fa-tachograph-digital"></i> <span>我的设备</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg fixed" id="page-header" style="background-image:url(https://p.liiiu.cn/i/2025/04/08/67f49876a62e5.webp)"><nav id="nav"><div class="more-app-btn"><i class="fa-solid fa-fingerprint fa-fw"></i><div class="more-app-list-groups"><div class="more-app-list-groups-container"><div class="more-app-list-group"><div class="more-app-list-title">🦄常用网站</div><div class="more-app-list"><a class="more-app-list-item" href="https://www.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-house"></i><span class="more-app-item-text">个人主页</span></a><a class="more-app-list-item" href="https://blog.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-blog"></i><span class="more-app-item-text">个人博客</span></a><a class="more-app-list-item" href="https://xc.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-image"></i><span class="more-app-item-text">个人相册</span></a><a class="more-app-list-item" href="https://github.com/willow-god" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-brands fa-github"></i><span class="more-app-item-text">Github</span></a></div></div><div class="more-app-list-group"><div class="more-app-list-title">😎周边站点</div><div class="more-app-list"><a class="more-app-list-item" href="https://gist.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-code"></i><span class="more-app-item-text">代码片段</span></a><a class="more-app-list-item" href="https://mm.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-pen-nib"></i><span class="more-app-item-text">提笔摘星</span></a><a class="more-app-list-item" href="https://pan.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-cloud"></i><span class="more-app-item-text">清羽云盘</span></a><a class="more-app-list-item" href="https://um.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-people-group"></i><span class="more-app-item-text">访客统计</span></a><a class="more-app-list-item" href="https://img.liiiu.cn/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-images"></i><span class="more-app-item-text">清羽图床</span></a><a class="more-app-list-item" href="https://chat.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-robot"></i><span class="more-app-item-text">清羽AI</span></a><a class="more-app-list-item" href="https://bsz.liiiu.cn/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-chart-pie"></i><span class="more-app-item-text">不蒜计数</span></a><a class="more-app-list-item" href="https://status.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-server"></i><span class="more-app-item-text">服务检测</span></a></div></div><div class="more-app-list-group"><div class="more-app-list-title">🚁实用工具</div><div class="more-app-list"><a class="more-app-list-item" href="https://tmail.qyliu.top/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-envelope"></i><span class="more-app-item-text">临时邮箱</span></a><a class="more-app-list-item" href="https://hot.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-fire"></i><span class="more-app-item-text">每日热榜</span></a><a class="more-app-list-item" href="https://cover.qyliu.top/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-eye"></i><span class="more-app-item-text">封面设计</span></a><a class="more-app-list-item" href="https://mini-cover.qyliu.top/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-image"></i><span class="more-app-item-text">迷你封面</span></a><a class="more-app-list-item" href="https://icon.qyliu.top/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-icons"></i><span class="more-app-item-text">万能图标</span></a><a class="more-app-list-item" href="https://draw.qyliu.top/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-paintbrush"></i><span class="more-app-item-text">灵感白板</span></a><a class="more-app-list-item" href="https://mindmap.qyliu.top/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-network-wired"></i><span class="more-app-item-text">思维导图</span></a><a class="more-app-list-item" href="https://share.liushen.fun/#/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-share-nodes"></i><span class="more-app-item-text">内容中转</span></a></div></div></div></div></div><span id="blog-info"><a class="nav-site-title" href="/" title="LiuShen's Blog"><span class="site-name">LiuShen</span></a></span><div id="menus"></div><div class="menus_items visible"><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fas fa-home"></i> <span>导航</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.liushen.fun/"><i class="fa-fw fa-solid fa-house-flag"></i> <span>个人主页</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://xc.liushen.fun/"><i class="fa-fw fa fa-camera-retro"></i> <span>个人相册</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa fa-graduation-cap"></i> <span>整理</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i> <span>时光卷轴</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i> <span>文章标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i> <span>文章分类</span></a></li><li><a class="site-page child" href="/charts/"><i class="fa-fw fa-solid fa-chart-pie"></i> <span>文章通览</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa-solid fa-user-group"></i> <span>友人</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/link/"><i class="fa-fw fas fa-link"></i> <span>友链展示</span></a></li><li><a class="site-page child" href="/addlink/"><i class="fa-fw fa fa-at"></i> <span>友链申请</span></a></li><li><a class="site-page child" href="/fcircle/"><i class="fa-fw fa-solid fa-circle-nodes"></i> <span>朋友动态</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa fa-paper-plane"></i> <span>留言</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/comment/"><i class="fa-fw fa-solid fa-chalkboard"></i> <span>留言白板</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://mm.liushen.fun/"><i class="fa-fw fa-solid fa-pen-nib"></i> <span>提笔摘星</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa-solid fa-stethoscope"></i> <span>分享</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://gist.liushen.fun/"><i class="fa-fw fa-solid fa-code"></i> <span>代码片段</span></a></li><li><a class="site-page child" href="/subscribe/"><i class="fa-fw fa-solid fa-rss"></i> <span>订阅本站</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://pan.liushen.fun/"><i class="fa-fw fa-solid fa-laptop-file"></i> <span>清羽云盘</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa fa-list"></i> <span>关于</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/about/"><i class="fa-fw fa fa-address-card"></i> <span>站长资料</span></a></li><li><a class="site-page child" href="/shuoshuo/"><i class="fa-fw fa fa-commenting"></i> <span>日常说说</span></a></li><li><a class="site-page child" href="/devices/"><i class="fa-fw fa-solid fa-tachograph-digital"></i> <span>我的设备</span></a></li></ul></div></div><center id="name-container"><a id="page-name" href="javascript:btf.scrollToDest(0, 500)">PAGE_NAME</a></center><div id="nav-right"><div id="travellings"><a class="site-page" href="https://www.travellings.cn/go.html" title="友链接力-随机开往" target="_blank" rel="noopener nofollow"><i class="fa-solid fa-bus fa-fw"></i></a></div><div id="ten-years"><a class="site-page" href="https://foreverblog.cn/go.html" title="友链接力-十年之约" target="_blank" rel="noopener nofollow"><i class="fa-brands fa-nfc-symbol fa-fw"></i></a></div><div id="random"><a class="site-page" href="javascript:randomPost()" title="随机前往一个文章"><i class="fa-solid fa-shuffle fa-fw"></i></a></div><div id="search-button"><span class="site-page social-icon search"><i class="fas fa-search fa-fw"></i></span></div><div id="toggle-menu"><span class="site-page" href="javascript:void(0);" title="展开菜单"><i class="fas fa-indent fa-fw"></i></span></div></div></nav><div id="post-info"><h1 class="post-title">PaddleYOLO训练自己的数据集</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2025-04-08T07:27:21.000Z" title="发表于 2025-04-08 15:27:21">2025-04-08</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2025-04-08T07:28:21.000Z" title="更新于 2025-04-08 15:28:21">2025-04-08</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/learning/">学习资料</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">总字数:</span><span class="word-count">5.6k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>21分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" data-flag-title=""><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">浏览量:</span><span id="busuanzi_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span><span class="post-meta-separator">|</span><span class="post-meta-commentcount"><i class="far fa-comments fa-fw post-meta-icon"></i><span class="post-meta-label">评论数:</span><a href="/posts/4bb33804/#post-comment"><span id="ArtalkCount"><i class="fa-solid fa-spinner fa-spin"></i></span></a></span></div></div></div><section class="main-hero-waves-area waves-area"><svg class="waves-svg" xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto"><defs><path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s58 18 88 18 58-18 88-18 58 18 88 18v44h-352Z"></path></defs><g class="parallax"><use href="#gentle-wave" x="48" y="0"></use><use href="#gentle-wave" x="48" y="3"></use><use href="#gentle-wave" x="48" y="5"></use><use href="#gentle-wave" x="48" y="7"></use></g></svg></section></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><div class="ai-summary"><div class="ai-head"><div class="ai-head-left"><div class="ai-circle ai-circle-1"></div><div class="ai-circle ai-circle-2"></div><div class="ai-circle ai-circle-3"></div></div><div class="ai-head-right"><a class="ai-about-ai" href="/posts/40702a0d/">关于AI</a></div></div><div class="ai-explanation" style="display:block" data-summary="这里是清羽AI，这篇文章介绍了如何使用PaddleYOLO训练自己的数据集。作者在毕业设计中使用了PaddleYOLO，发现教程较少，很多坑需要自行摸索，但最终成功跑通了训练和部署流程。文章首先介绍了PaddleYOLO的特点，包括高性能、轻量级、灵活可扩展和易于部署等优势，并说明了它支持的模型包括YOLOv3、YOLOv5、PP-YOLO和YOLOv8。接着，文章详细讲解了环境配置、数据预处理和模型配置等步骤，包括如何安装Python环境、PaddlePaddle和依赖包，如何准备和转换数据集格式，以及如何调整配置文件以适应自己的数据集。作者以船舶识别检测为例，说明了如何将VOC格式的数据集转换为COCO格式，并如何配置数据库和训练参数。最后，文章强调了PaddleYOLO在飞桨生态系统中的重要性，以及它在实际应用中的优势。">清羽AI正在绞尽脑汁想思路ING···</div><div class="ai-title"><div class="ai-title-left"><i class="fa-brands fa-slack"></i><div class="ai-title-text">清羽のAI摘要</div></div><div class="ai-tag" id="ai-tag">GLM-4-Flash</div></div></div><h2 id="碎碎念"><a href="#碎碎念" class="headerlink" title="碎碎念"></a>碎碎念</h2><p>最近一直在忙毕业设计，头发又少了一点（悲）。期间要用到目标检测这一块，研究了一下<code>PaddleYOLO</code>，发现教程是真不多，很多坑也没人填，官方仓库里的很多说明文件也不存在了，需要自行摸索。边踩边填的过程虽然痛苦，但也算成功跑通了训练 + 部署的完整流程。为了防止下一次又一脸懵逼地重头开始，这里写个记录，也希望能帮到后来人。</p><p>顺带一提，<code>PaddleYOLO</code>≠<code>PP-YOLO</code>，不要搞混了。<code>PaddleYOLO</code>是飞桨官方的目标检测套件，相当于是集成了各种检测模型的训练与部署框架。它目前支持的模型包括<code>YOLOv3</code>、<code>YOLOv5</code>、<code>PP-YOLO</code>、<code>PP-YOLOE</code>，<code>YOLO</code>系列最新支持到了<code>YOLOv8</code>，本次训练我们也基于<code>YOLOv8</code>进行展开讲解。</p><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL1BhZGRsZVBhZGRsZS9QYWRkbGVZT0xP" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2024/07/27/66a461a3098aa.webp)"></div><div class="tag-link-right"><div class="tag-link-title">PaddleYOLO:YOLO series of PaddlePaddle implementation</div><div class="tag-link-sitename">github.com@PaddlePaddle</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><p><strong>注意：</strong>本篇文章可能稍微有些枯燥乏味，因为是以实验报告的内容，可能没有一些华丽的辞藻，更多是关于相关领域的一些术词，可能仅供专业人士研究。</p><h2 id="介绍"><a href="#介绍" class="headerlink" title="介绍"></a>介绍</h2><p><code>PaddleYOLO</code>是基于飞桨框架开发的目标检测套件，专注于整合和优化 YOLO 系列模型，旨在提供高性能、轻量级且易于部署的目标检测解决方案。</p><h3 id="性能优势"><a href="#性能优势" class="headerlink" title="性能优势"></a>性能优势</h3><ul><li><strong>高性能</strong>：<code>PaddleYOLO</code>采用优化的计算图执行引擎，对模型进行了深度的硬件级优化，能够充分利用<code>GPU</code>和<code>CPU</code>资源，实现更快的推理速度。</li><li><strong>轻量级</strong>：模型结构紧凑，适合资源受限的设备，如嵌入式系统或移动设备，支持实时目标检测。</li><li><strong>灵活可扩展</strong>：支持多种<code>YOLO</code>架构，包括<code>YOLOv3</code>、<code>YOLOv5</code>、<code>YOLOv6</code>、<code>YOLOv7</code>、<code>YOLOv8</code>、<code>PP-YOLO</code>、<code>PP-YOLOE</code>、<code>RT-DETR</code>等，用户可根据实际需求调整网络配置，适应不同应用场景。</li><li><strong>易于部署</strong>：集成了 <code>Paddle Serving</code>，提供完整的模型服务解决方案，便于将模型部署到生产环境，具有良好的跨平台兼容性，支持在多种硬件平台上运行，包括昇腾<code>NPU</code>(<del>比如我们学校那个B鲲鹏平台</del>)。</li></ul><h3 id="模型支持列表"><a href="#模型支持列表" class="headerlink" title="模型支持列表"></a>模型支持列表</h3><table><thead><tr><th align="left">模型名称</th><th align="left">GitHub 仓库地址</th></tr></thead><tbody><tr><td align="left">YOLOv3</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL3VsdHJhbHl0aWNzL3lvbG92Mw">ultralytics/yolov3</a></td></tr><tr><td align="left">YOLOv5</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL3VsdHJhbHl0aWNzL3lvbG92NQ">ultralytics/yolov5</a></td></tr><tr><td align="left">YOLOv6</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL21laXR1YW4vWU9MT3Y2">meituan/YOLOv6</a></td></tr><tr><td align="left">YOLOv7</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL1dvbmdLaW5ZaXUveW9sb3Y3">WongKinYiu/yolov7</a></td></tr><tr><td align="left">YOLOv8</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL3VsdHJhbHl0aWNzL3VsdHJhbHl0aWNz">ultralytics/ultralytics</a></td></tr><tr><td align="left">PP-YOLO</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL1BhZGRsZVBhZGRsZS9QYWRkbGVEZXRlY3Rpb24vdHJlZS9yZWxlYXNlLzIuOC4xL2NvbmZpZ3MvcHB5b2xv">PaddlePaddle/PaddleDetection</a></td></tr><tr><td align="left">PP-YOLOv2</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL1BhZGRsZVBhZGRsZS9QYWRkbGVEZXRlY3Rpb24vdHJlZS9yZWxlYXNlLzIuOC4xL2NvbmZpZ3MvcHB5b2xvdjI">PaddlePaddle/PaddleDetection</a></td></tr><tr><td align="left">PP-YOLOE</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL1BhZGRsZVBhZGRsZS9QYWRkbGVEZXRlY3Rpb24vdHJlZS9yZWxlYXNlLzIuOC4xL2NvbmZpZ3MvcHB5b2xvZQ">PaddlePaddle/PaddleDetection</a></td></tr><tr><td align="left">PP-YOLOE+</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL1BhZGRsZVBhZGRsZS9QYWRkbGVEZXRlY3Rpb24vdHJlZS9yZWxlYXNlLzIuOC4xL2NvbmZpZ3MvcHB5b2xvZV9wbHVz">PaddlePaddle/PaddleDetection</a></td></tr><tr><td align="left">RT-DETR</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL2x5dXdlbnl1L1JULURFVFI">lyuwenyu/RT-DETR</a></td></tr><tr><td align="left">YOLOX</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL01lZ3ZpaS1CYXNlRGV0ZWN0aW9uL1lPTE9Y">Megvii-BaseDetection/YOLOX</a></td></tr><tr><td align="left">YOLOv5u</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL3VsdHJhbHl0aWNzL3lvbG92NQ">ultralytics/yolov5</a></td></tr><tr><td align="left">YOLOv7u</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL1dvbmdLaW5ZaXUveW9sb3Y3">WongKinYiu/yolov7</a></td></tr><tr><td align="left">YOLOv6Lite</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL21laXR1YW4vWU9MT3Y2L3RyZWUvbWFpbi9jb25maWdzL3lvbG92Nl9saXRl">meituan/YOLOv6</a></td></tr><tr><td align="left">RTMDet</td><td align="left"><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL29wZW4tbW1sYWIvbW1kZXRlY3Rpb24vdHJlZS9tYWluL2NvbmZpZ3MvcnRtZGV0">open-mmlab/mmdetection</a></td></tr></tbody></table><h3 id="MMYOLO对比"><a href="#MMYOLO对比" class="headerlink" title="MMYOLO对比"></a>MMYOLO对比</h3><p><code>MMYOLO</code>是基于<code>OpenMMLab</code>开发的目标检测框架，具有模块化设计，允许轻松定制和扩展，适合研究和开发新技术，相比之下，<code>PaddleYOLO</code>专注于飞桨生态系统，针对飞桨框架进行了优化，提供了高性能和轻量级的目标检测解决方案，特别适合需要与其他飞桨项目（如 PPOCR）集成的应用场景。在本项目的第二阶段，需要使用<code>PPOCR</code>进行文字检测与识别。为了保持框架的一致性，减少跨框架通信和转换的复杂性，在这里我选择了与<code>PPOCR</code>同属飞桨生态的<code>PaddleYOLO</code>作为目标检测模块。</p><p>下面我将详细了解一下如何使用<code>PaddleYOLO</code>进行训练内容。</p><h2 id="环境配置"><a href="#环境配置" class="headerlink" title="环境配置"></a>环境配置</h2><p>首先克隆<code>PaddleYOLO</code>仓库：</p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git <span class="built_in">clone</span> https://github.com/PaddlePaddle/PaddleYOLO.git</span><br><span class="line"><span class="built_in">cd</span> PaddleYOLO</span><br></pre></td></tr></tbody></table></figure><h3 id="Python"><a href="#Python" class="headerlink" title="Python"></a>Python</h3><p>首先创建一个<code>Python</code>环境，经过我测试，强烈建议<code>3.10</code>环境，可以最大的兼容，如果你使用的<code>conda</code>，使用以下命令：</p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">conda create -n myenv python=3.10</span><br><span class="line">conda activate myenv</span><br></pre></td></tr></tbody></table></figure><p>创建环境后，安装一些依赖包：</p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install -r requirements.txt  <span class="comment"># install</span></span><br></pre></td></tr></tbody></table></figure><p>下面需要安装<code>PaddlePaddle</code>。</p><h3 id="PaddlePaddle"><a href="#PaddlePaddle" class="headerlink" title="PaddlePaddle"></a>PaddlePaddle</h3><p>首先点击下方链接打开官网：</p><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly93d3cucGFkZGxlcGFkZGxlLm9yZy5jbi8" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2024/07/27/66a4632bbf06e.webp)"></div><div class="tag-link-right"><div class="tag-link-title">飞桨新一代框架3.0</div><div class="tag-link-sitename">源于产业实践的开源深度学习平台</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><p>向下滑到快速安装部分，如果<code>cuda</code>没有合适的版本可以向上选择，执行命令的过程中可能会有很多报错，不要慌张，这都是因为依赖包的问题，按照要求安装对应包即可。</p><h2 id="数据预处理"><a href="#数据预处理" class="headerlink" title="数据预处理"></a>数据预处理</h2><h3 id="数据格式"><a href="#数据格式" class="headerlink" title="数据格式"></a>数据格式</h3><p>在<code>PaddleYOLO</code>中，数据集是支持了三种格式的，分别为<code>VOC</code>、<code>COCO</code>和<code>YOLO</code>专用数据集，三者的格式分别如下：</p><ol><li><p><strong>VOC格式：</strong></p><p><code>PASCAL VOC</code>数据集的目录结构通常如下：</p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">VOCdevkit/</span><br><span class="line">├── VOC2007/</span><br><span class="line">│   ├── Annotations/        <span class="comment"># 存放 XML 格式的标注文件</span></span><br><span class="line">│   ├── JPEGImages/         <span class="comment"># 存放图像文件</span></span><br><span class="line">│   ├── ImageSets/</span><br><span class="line">│   │   └── Main/</span><br><span class="line">│   │       ├── train.txt   <span class="comment"># 训练集文件名列表</span></span><br><span class="line">│   │       ├── val.txt     <span class="comment"># 验证集文件名列表</span></span><br><span class="line">│   │       └── test.txt    <span class="comment"># 测试集文件名列表</span></span><br></pre></td></tr></tbody></table></figure><p>在<code>Annotations/</code>目录下，每个 XML 文件对应一张图像，包含该图像中目标的边界框、类别等信息。</p><p><code>VOC</code>格式是一个较为传统的数据结构，使用<code>XML</code>文件描述每张图片的标注信息，结构直观、易于阅读。著名标注工具<code>LabelMe</code>的结果就是<code>VOC</code>格式，在早期的目标检测任务中被程序员广泛使用，适合初学者入门和教学场景，但由于不够灵活，难以支持像分割或关键点检测这样的高级任务，现在的使用率已大幅下降。</p></li><li><p><strong>COCO格式：</strong></p><p><code>COCO</code>数据集的目录结构示例如下：</p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">coco/</span><br><span class="line">├── annotations/</span><br><span class="line">│   ├── instances_train2017.json  <span class="comment"># 训练集标注文件</span></span><br><span class="line">│   ├── instances_val2017.json    <span class="comment"># 验证集标注文件</span></span><br><span class="line">├── images/</span><br><span class="line">│   ├── train2017/                <span class="comment"># 训练集图像</span></span><br><span class="line">│   └── val2017/                  <span class="comment"># 验证集图像</span></span><br></pre></td></tr></tbody></table></figure><p>在 <code>annotations/</code> 目录下，标注文件为 JSON 格式，包含图像信息、类别信息、目标的边界框等。</p><p>在目标检测任务中，我们最常用且通用性最强的数据格式是<strong>COCO 格式</strong>。相比于<code>VOC</code>和<code>YOLO</code>格式，<code>COCO</code>拥有更丰富的结构设计和信息表达能力，它不仅支持物体检测，还可以扩展到实例分割、关键点检测、多标签分类等任务，因此被广泛应用于商业级项目和科研场景。几乎所有主流的检测框架，包括<code>MMDetection</code>、<code>YOLOv5/v8</code>、<code>PaddleYOLO</code>等，都原生支持<code>COCO</code>格式的数据，使其在模型训练、测试和部署中都非常方便。</p></li><li><p><strong>YOLO格式：</strong></p><p><code>YOLO</code>格式的数据集目录结构通常如下：</p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">yolo_dataset/</span><br><span class="line">├── images/</span><br><span class="line">│   ├── train/       <span class="comment"># 训练集图像</span></span><br><span class="line">│   ├── val/         <span class="comment"># 验证集图像</span></span><br><span class="line">│   └── <span class="built_in">test</span>/        <span class="comment"># 测试集图像（可选）</span></span><br><span class="line">├── labels/</span><br><span class="line">│   ├── train/       <span class="comment"># 训练集标注文件</span></span><br><span class="line">│   ├── val/         <span class="comment"># 验证集标注文件</span></span><br><span class="line">│   └── <span class="built_in">test</span>/        <span class="comment"># 测试集标注文件（可选）</span></span><br></pre></td></tr></tbody></table></figure><p>在 <code>labels/</code> 目录下，每个标注文件对应一张图像，采用纯文本格式，每行表示一个目标，包含类别索引、边界框中心坐标、宽度和高度，所有值均为归一化后的相对值。</p><p><code>YOLO</code>专用格式则以极简著称，每张图像对应一个 <code>.txt</code> 文件，每行标注一个目标，格式紧凑、易于解析，适合在资源受限或对实时性要求高的边缘设备中使用。不过，其表达能力有限，仅支持类别与边框信息，不适用于需要更复杂标注的任务，并且在一些检测框架中仍需手动转换为<code>COCO</code>格式才能使用。</p></li></ol><p>因此，综合考虑框架兼容性、后续扩展性以及整体便携性，我个人更加推荐在<code>PaddleYOLO</code>中使用<code>COCO</code>格式的数据集。</p><h3 id="数据准备"><a href="#数据准备" class="headerlink" title="数据准备"></a>数据准备</h3><p>本次毕设我选择了船舶方向的研究，所以这里我采用了两个知名航海船舶数据集：<code>Seaships</code>和<code>MCShips</code>，链接如下：</p><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL2ppYW1pbmctd2FuZy9TZWFTaGlwcw" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2024/07/27/66a461a3098aa.webp)"></div><div class="tag-link-right"><div class="tag-link-title">Seaships: A large-scale precisely annotated dataset for ship detection</div><div class="tag-link-sitename">github.com@jiaming-wang</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL1poZW5nWWl0b25nMjMzMy9NY3NoaXBz" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2024/07/27/66a461a3098aa.webp)"></div><div class="tag-link-right"><div class="tag-link-title">Mcships database in Pascal-VOC</div><div class="tag-link-sitename">github.com@ZhengYitong2333</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><p>这里我就以第一个为例，如果需要融合数据，只需要修改代码的类别数量即可。</p><h3 id="格式转换"><a href="#格式转换" class="headerlink" title="格式转换"></a>格式转换</h3><p>以上二者数据都是<code>VOC</code>格式的，这里我在网上找到了以下代码进行转换：</p><figure class="highlight python"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> os</span><br><span class="line"><span class="keyword">import</span> cv2</span><br><span class="line"><span class="keyword">import</span> json</span><br><span class="line"><span class="keyword">import</span> shutil</span><br><span class="line"><span class="keyword">import</span> xml.etree.ElementTree <span class="keyword">as</span> ET</span><br><span class="line"><span class="keyword">from</span> tqdm <span class="keyword">import</span> tqdm</span><br><span class="line"> </span><br><span class="line"><span class="comment"># Seaships 数据集的类别</span></span><br><span class="line">SEASHIPS_CLASSES = (</span><br><span class="line">        <span class="string">'ore carrier'</span>, <span class="string">'bulk cargo carrier'</span>, <span class="string">'general cargo ship'</span>, <span class="string">'container ship'</span>, <span class="string">'fishing boat'</span>, <span class="string">'passenger ship'</span></span><br><span class="line">        <span class="comment"># 'warship', 'civilianship'</span></span><br><span class="line">)</span><br><span class="line"> </span><br><span class="line"><span class="comment"># 将类别名称映射为 COCO 格式的 category_id</span></span><br><span class="line">label_ids = {name: i + <span class="number">1</span> <span class="keyword">for</span> i, name <span class="keyword">in</span> <span class="built_in">enumerate</span>(SEASHIPS_CLASSES)}</span><br><span class="line"> </span><br><span class="line"><span class="keyword">def</span> <span class="title function_">parse_xml</span>(<span class="params">xml_path</span>):</span><br><span class="line">    <span class="string">"""</span></span><br><span class="line"><span class="string">    解析 XML 文件，提取标注信息。</span></span><br><span class="line"><span class="string">    """</span></span><br><span class="line">    tree = ET.parse(xml_path)</span><br><span class="line">    root = tree.getroot()</span><br><span class="line"> </span><br><span class="line">    objects = []</span><br><span class="line">    <span class="keyword">for</span> obj <span class="keyword">in</span> root.findall(<span class="string">'object'</span>):</span><br><span class="line">        <span class="comment"># 解析类别名称</span></span><br><span class="line">        name = obj.find(<span class="string">'name'</span>).text</span><br><span class="line">        <span class="keyword">if</span> name <span class="keyword">not</span> <span class="keyword">in</span> label_ids:</span><br><span class="line">            <span class="built_in">print</span>(<span class="string">f"警告: 未知类别 '<span class="subst">{name}</span>'，跳过该对象。"</span>)</span><br><span class="line">            <span class="keyword">continue</span></span><br><span class="line"> </span><br><span class="line">        <span class="comment"># 解析 difficult 标签</span></span><br><span class="line">        difficult_tag = obj.find(<span class="string">'difficult'</span>)</span><br><span class="line">        difficult = <span class="built_in">int</span>(difficult_tag.text) <span class="keyword">if</span> difficult_tag <span class="keyword">is</span> <span class="keyword">not</span> <span class="literal">None</span> <span class="keyword">else</span> <span class="number">0</span></span><br><span class="line"> </span><br><span class="line">        <span class="comment"># 解析边界框</span></span><br><span class="line">        bnd_box = obj.find(<span class="string">'bndbox'</span>)</span><br><span class="line">        <span class="keyword">if</span> bnd_box <span class="keyword">is</span> <span class="keyword">not</span> <span class="literal">None</span>:</span><br><span class="line">            bbox = [</span><br><span class="line">                <span class="built_in">int</span>(bnd_box.find(<span class="string">'xmin'</span>).text),</span><br><span class="line">                <span class="built_in">int</span>(bnd_box.find(<span class="string">'ymin'</span>).text),</span><br><span class="line">                <span class="built_in">int</span>(bnd_box.find(<span class="string">'xmax'</span>).text),</span><br><span class="line">                <span class="built_in">int</span>(bnd_box.find(<span class="string">'ymax'</span>).text)</span><br><span class="line">            ]</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            <span class="built_in">print</span>(<span class="string">f"警告: 在文件 <span class="subst">{xml_path}</span> 中未找到 &lt;bndbox&gt; 标签，跳过该对象。"</span>)</span><br><span class="line">            <span class="keyword">continue</span></span><br><span class="line"> </span><br><span class="line">        <span class="comment"># 添加到对象列表</span></span><br><span class="line">        objects.append({</span><br><span class="line">            <span class="string">'name'</span>: name,</span><br><span class="line">            <span class="string">'label_id'</span>: label_ids[name],</span><br><span class="line">            <span class="string">'difficult'</span>: difficult,</span><br><span class="line">            <span class="string">'bbox'</span>: bbox</span><br><span class="line">        })</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">return</span> objects</span><br><span class="line"> </span><br><span class="line"><span class="keyword">def</span> <span class="title function_">load_split_files</span>(<span class="params">split_dir</span>):</span><br><span class="line">    <span class="string">"""</span></span><br><span class="line"><span class="string">    加载划分文件（train.txt, val.txt, test.txt）。</span></span><br><span class="line"><span class="string">    """</span></span><br><span class="line">    split_files = {}</span><br><span class="line">    <span class="keyword">for</span> split_name <span class="keyword">in</span> [<span class="string">'train'</span>, <span class="string">'val'</span>, <span class="string">'test'</span>]:</span><br><span class="line">        split_path = os.path.join(split_dir, <span class="string">f'<span class="subst">{split_name}</span>.txt'</span>)</span><br><span class="line">        <span class="keyword">if</span> os.path.exists(split_path):</span><br><span class="line">            <span class="keyword">with</span> <span class="built_in">open</span>(split_path, <span class="string">'r'</span>) <span class="keyword">as</span> f:</span><br><span class="line">                split_files[split_name] = [line.strip() <span class="keyword">for</span> line <span class="keyword">in</span> f.readlines()]</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            <span class="built_in">print</span>(<span class="string">f"警告: 未找到 <span class="subst">{split_name}</span>.txt 文件，跳过该划分。"</span>)</span><br><span class="line">            split_files[split_name] = []</span><br><span class="line">    <span class="keyword">return</span> split_files</span><br><span class="line"> </span><br><span class="line"><span class="keyword">def</span> <span class="title function_">convert_to_coco</span>(<span class="params">image_dir, xml_dir, split_dir, output_dir</span>):</span><br><span class="line">    <span class="string">"""</span></span><br><span class="line"><span class="string">    将 Seaships 数据集转换为 COCO 格式，并根据划分文件划分数据集。</span></span><br><span class="line"><span class="string">    """</span></span><br><span class="line">    <span class="comment"># 创建输出目录</span></span><br><span class="line">    os.makedirs(os.path.join(output_dir, <span class="string">'annotations'</span>), exist_ok=<span class="literal">True</span>)</span><br><span class="line">    os.makedirs(os.path.join(output_dir, <span class="string">'train'</span>), exist_ok=<span class="literal">True</span>)</span><br><span class="line">    os.makedirs(os.path.join(output_dir, <span class="string">'val'</span>), exist_ok=<span class="literal">True</span>)</span><br><span class="line">    os.makedirs(os.path.join(output_dir, <span class="string">'test'</span>), exist_ok=<span class="literal">True</span>)</span><br><span class="line"> </span><br><span class="line">    <span class="comment"># 加载划分文件</span></span><br><span class="line">    split_files = load_split_files(split_dir)</span><br><span class="line"> </span><br><span class="line">    <span class="comment"># 定义 COCO 格式的基本结构</span></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">create_coco_structure</span>():</span><br><span class="line">        <span class="keyword">return</span> {</span><br><span class="line">            <span class="string">"info"</span>: {</span><br><span class="line">                <span class="string">"description"</span>: <span class="string">"Seaships Dataset"</span>,</span><br><span class="line">                <span class="string">"version"</span>: <span class="string">"1.0"</span>,</span><br><span class="line">                <span class="string">"year"</span>: <span class="number">2023</span>,</span><br><span class="line">                <span class="string">"contributor"</span>: <span class="string">"Your Name"</span>,</span><br><span class="line">                <span class="string">"date_created"</span>: <span class="string">"2023-10-01"</span></span><br><span class="line">            },</span><br><span class="line">            <span class="string">"licenses"</span>: [],</span><br><span class="line">            <span class="string">"images"</span>: [],</span><br><span class="line">            <span class="string">"annotations"</span>: [],</span><br><span class="line">            <span class="string">"categories"</span>: [</span><br><span class="line">                {<span class="string">"id"</span>: i + <span class="number">1</span>, <span class="string">"name"</span>: name, <span class="string">"supercategory"</span>: <span class="string">"none"</span>}</span><br><span class="line">                <span class="keyword">for</span> i, name <span class="keyword">in</span> <span class="built_in">enumerate</span>(SEASHIPS_CLASSES)</span><br><span class="line">            ]</span><br><span class="line">        }</span><br><span class="line"> </span><br><span class="line">    <span class="comment"># 处理每个数据集</span></span><br><span class="line">    <span class="keyword">for</span> split_name, file_names <span class="keyword">in</span> split_files.items():</span><br><span class="line">        coco_data = create_coco_structure()</span><br><span class="line">        annotation_id = <span class="number">1</span></span><br><span class="line"> </span><br><span class="line">        <span class="keyword">for</span> file_name <span class="keyword">in</span> tqdm(file_names, desc=<span class="string">f"处理 <span class="subst">{split_name}</span> 数据集"</span>):</span><br><span class="line">            xml_file = os.path.join(xml_dir, <span class="string">f'<span class="subst">{file_name}</span>.xml'</span>)</span><br><span class="line">            image_name = <span class="string">f'<span class="subst">{file_name}</span>.jpg'</span></span><br><span class="line">            image_path = os.path.join(image_dir, image_name)</span><br><span class="line"> </span><br><span class="line">            <span class="comment"># 检查图像文件和 XML 文件是否存在</span></span><br><span class="line">            <span class="keyword">if</span> <span class="keyword">not</span> os.path.exists(image_path):</span><br><span class="line">                <span class="built_in">print</span>(<span class="string">f"警告: 图像文件 <span class="subst">{image_name}</span> 不存在，跳过该标注文件。"</span>)</span><br><span class="line">                <span class="keyword">continue</span></span><br><span class="line">            <span class="keyword">if</span> <span class="keyword">not</span> os.path.exists(xml_file):</span><br><span class="line">                <span class="built_in">print</span>(<span class="string">f"警告: 标注文件 <span class="subst">{xml_file}</span> 不存在，跳过该图像文件。"</span>)</span><br><span class="line">                <span class="keyword">continue</span></span><br><span class="line"> </span><br><span class="line">            <span class="comment"># 读取图像尺寸</span></span><br><span class="line">            image = cv2.imread(image_path)</span><br><span class="line">            height, width, _ = image.shape</span><br><span class="line"> </span><br><span class="line">            <span class="comment"># 添加图像信息</span></span><br><span class="line">            image_id = <span class="built_in">len</span>(coco_data[<span class="string">'images'</span>]) + <span class="number">1</span></span><br><span class="line">            coco_data[<span class="string">'images'</span>].append({</span><br><span class="line">                <span class="string">"id"</span>: image_id,</span><br><span class="line">                <span class="string">"file_name"</span>: image_name,</span><br><span class="line">                <span class="string">"width"</span>: width,</span><br><span class="line">                <span class="string">"height"</span>: height</span><br><span class="line">            })</span><br><span class="line"> </span><br><span class="line">            <span class="comment"># 解析 XML 文件</span></span><br><span class="line">            objects = parse_xml(xml_file)</span><br><span class="line">            <span class="keyword">for</span> obj <span class="keyword">in</span> objects:</span><br><span class="line">                xmin, ymin, xmax, ymax = obj[<span class="string">'bbox'</span>]</span><br><span class="line">                bbox = [xmin, ymin, xmax - xmin, ymax - ymin]  <span class="comment"># COCO 格式的 bbox 是 [x, y, width, height]</span></span><br><span class="line">                area = (xmax - xmin) * (ymax - ymin)</span><br><span class="line"> </span><br><span class="line">                coco_data[<span class="string">'annotations'</span>].append({</span><br><span class="line">                    <span class="string">"id"</span>: annotation_id,</span><br><span class="line">                    <span class="string">"image_id"</span>: image_id,</span><br><span class="line">                    <span class="string">"category_id"</span>: obj[<span class="string">'label_id'</span>],</span><br><span class="line">                    <span class="string">"bbox"</span>: bbox,</span><br><span class="line">                    <span class="string">"area"</span>: area,</span><br><span class="line">                    <span class="string">"iscrowd"</span>: <span class="number">0</span>,</span><br><span class="line">                    <span class="string">"difficult"</span>: obj[<span class="string">'difficult'</span>]</span><br><span class="line">                })</span><br><span class="line">                annotation_id += <span class="number">1</span></span><br><span class="line"> </span><br><span class="line">            <span class="comment"># 复制图像文件到对应的文件夹</span></span><br><span class="line">            shutil.copy(image_path, os.path.join(output_dir, split_name, image_name))</span><br><span class="line"> </span><br><span class="line">        <span class="comment"># 保存 COCO 格式的标注文件</span></span><br><span class="line">        <span class="keyword">with</span> <span class="built_in">open</span>(os.path.join(output_dir, <span class="string">'annotations'</span>, <span class="string">f'instances_<span class="subst">{split_name}</span>.json'</span>), <span class="string">'w'</span>) <span class="keyword">as</span> f:</span><br><span class="line">            json.dump(coco_data, f, indent=<span class="number">4</span>)</span><br><span class="line"> </span><br><span class="line">    <span class="built_in">print</span>(<span class="string">f"转换完成，结果已保存到 <span class="subst">{output_dir}</span>"</span>)</span><br><span class="line"> </span><br><span class="line"><span class="comment"># 设置路径</span></span><br><span class="line">image_dir = <span class="string">".\dataset\Mcship_lite\JPEGImages"</span>  <span class="comment"># 图像文件目录</span></span><br><span class="line">xml_dir = <span class="string">".\dataset\Mcship_lite\Annotations"</span>  <span class="comment"># XML 标注文件目录</span></span><br><span class="line">split_dir = <span class="string">".\dataset\Mcship_lite\ImageSets\Main"</span>  <span class="comment"># 划分文件目录（包含 train.txt, val.txt, test.txt）</span></span><br><span class="line">output_dir = <span class="string">".\dataset\Mcship_lite-coco"</span>  <span class="comment"># 输出的 COCO 格式文件夹</span></span><br><span class="line"> </span><br><span class="line"><span class="comment"># 执行转换</span></span><br><span class="line">convert_to_coco(image_dir, xml_dir, split_dir, output_dir)</span><br></pre></td></tr></tbody></table></figure><p>只需要修改下面的路径即可，最终会直接输出标准格式的<code>COCO</code>数据集，这样我们的数据预处理部分也就实现了。</p><h2 id="调整配置"><a href="#调整配置" class="headerlink" title="调整配置"></a>调整配置</h2><p>下面我们需要修改一些配置，通过配置，正确的指向我们所需要的模型，数据。</p><h3 id="数据库配置"><a href="#数据库配置" class="headerlink" title="数据库配置"></a>数据库配置</h3><p>首先配置数据库，为了方便，我们将数据库放置在了<code>PaddleYOLO/dataset</code>文件夹内，然后开始配置，如果文件克隆完整，我们可以在<code>PaddleYOLO/configs/datasets</code>目录下看到一些数据集配置：</p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">PaddleYOLO/</span><br><span class="line">├── configs/</span><br><span class="line">│   ├── datasets/</span><br><span class="line">│   │   ├── Coco_Detection.yml           <span class="comment"># 配置 COCO 数据集，用于物体检测任务</span></span><br><span class="line">│   │   ├── Coco_instance.yml            <span class="comment"># 配置 COCO 数据集的实例分割任务</span></span><br><span class="line">│   │   ├── object365_Detection.yml      <span class="comment"># 配置 Object365 数据集，用于多类物体检测任务</span></span><br><span class="line">│   │   ├── OpenImagesv7_Detection.yml   <span class="comment"># 配置 Open Images v7 数据集，用于大规模目标检测任务</span></span><br><span class="line">│   │   ├── roadsign_voc.yml             <span class="comment"># 配置 RoadSign 数据集，用于交通标志检测任务，兼容 VOC 格式</span></span><br><span class="line">│   │   ├── Visdrone_Detection.yml       <span class="comment"># 配置 VisDrone 数据集，用于无人机图像物体检测与追踪</span></span><br><span class="line">│   │   └── Voc.yml                      <span class="comment"># 配置 PASCAL VOC 数据集，用于传统物体检测任务</span></span><br></pre></td></tr></tbody></table></figure><p>按照我们的要求，我们进行的是船舶识别检测，所以选择第一个配置文件作为基础文件，复制该文件，比如这里我是创建了一个<code>Coco_Detection_Mydataset.yml</code>文件，存储我个人的数据集配置，内容如下：</p><figure class="highlight yaml"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">metric:</span> <span class="string">COCO</span></span><br><span class="line"><span class="attr">num_classes:</span> <span class="number">6</span></span><br><span class="line"></span><br><span class="line"><span class="attr">TrainDataset:</span></span><br><span class="line">  <span class="attr">name:</span> <span class="string">COCODataSet</span></span><br><span class="line">  <span class="attr">image_dir:</span> <span class="string">train</span></span><br><span class="line">  <span class="attr">anno_path:</span> <span class="string">annotations/instances_train.json</span></span><br><span class="line">  <span class="attr">dataset_dir:</span> <span class="string">dataset/SeaShips-coco</span></span><br><span class="line">  <span class="attr">data_fields:</span> [<span class="string">'image'</span>, <span class="string">'gt_bbox'</span>, <span class="string">'gt_class'</span>, <span class="string">'is_crowd'</span>]</span><br><span class="line"></span><br><span class="line"><span class="attr">EvalDataset:</span></span><br><span class="line">  <span class="attr">name:</span> <span class="string">COCODataSet</span></span><br><span class="line">  <span class="attr">image_dir:</span> <span class="string">val</span></span><br><span class="line">  <span class="attr">anno_path:</span> <span class="string">annotations/instances_val.json</span> <span class="comment"># annotations/instances_val.json</span></span><br><span class="line">  <span class="attr">dataset_dir:</span> <span class="string">dataset/SeaShips-coco</span></span><br><span class="line"></span><br><span class="line"><span class="attr">TestDataset:</span></span><br><span class="line">  <span class="attr">name:</span> <span class="string">ImageFolder</span></span><br><span class="line">  <span class="attr">image_dir:</span> <span class="string">test</span> <span class="comment"># test</span></span><br><span class="line">  <span class="attr">anno_path:</span> <span class="string">annotations/instances_test.json</span> <span class="comment"># annotations/instances_val.json # also support txt (like VOC's label_list.txt)</span></span><br><span class="line">  <span class="attr">dataset_dir:</span> <span class="string">dataset/SeaShips-coco</span> <span class="comment"># if set, anno_path will be 'dataset_dir/anno_path'</span></span><br></pre></td></tr></tbody></table></figure><p>需要修改的内容是第二行的类别，和每个里面的路径和地址，这里用的相对地址，注意个人存放路径，其他不要修改。</p><h3 id="训练配置"><a href="#训练配置" class="headerlink" title="训练配置"></a>训练配置</h3><p>这里我用的是<code>YOLOv8</code>，并且选择了<code>M*</code>版本模型，是一个兼顾速度和效果的版本，找到目录<code>PaddleYOLO\configs\yolov8</code>，目录如下：</p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">PaddleYOLO/</span><br><span class="line">├── configs/</span><br><span class="line">│   ├── yolov8/</span><br><span class="line">│   │   ├── _base_</span><br><span class="line">│   │   ├── openimagev7                     <span class="comment"># 配置 OpenImages v7 数据集的 YOLOv8 训练</span></span><br><span class="line">│   │   ├── README.md                       <span class="comment"># 该文件包含 YOLOv8 配置的说明和使用方法</span></span><br><span class="line">│   │   ├── yolov8_l_500e_coco.yml            <span class="comment"># 配置 YOLOv8 使用 COCO 数据集，训练 500 epochs，模型为 L 版本</span></span><br><span class="line">│   │   ├── yolov8_m_500e_coco.yml          <span class="comment"># 配置 YOLOv8 使用 COCO 数据集，训练 500 epochs，模型为 M 版本</span></span><br><span class="line">│   │   ├── yolov8_n_500e_coco.yml          <span class="comment"># 配置 YOLOv8 使用 COCO 数据集，训练 500 epochs，模型为 N 版本</span></span><br><span class="line">│   │   ├── yolov8_s_500e_coco.yml          <span class="comment"># 配置 YOLOv8 使用 COCO 数据集，训练 500 epochs，模型为 S 版本</span></span><br><span class="line">│   │   ├── yolov8_x_500e_coco.yml          <span class="comment"># 配置 YOLOv8 使用 COCO 数据集，训练 500 epochs，模型为 X 版本</span></span><br><span class="line">│   │   └── yolov8p6_x_500e_coco.yml        <span class="comment"># 配置 YOLOv8p6 使用 COCO 数据集，训练 500 epochs，模型为 X 版本</span></span><br></pre></td></tr></tbody></table></figure><p>以上不同的配置文件表示不同的模型版本，以下是这些配置文件的简要说明：</p><table><thead><tr><th>配置文件</th><th>模型版本</th><th>训练数据集</th><th>训练周期</th><th>说明</th></tr></thead><tbody><tr><td><code>yolov8_l_500e_coco.yml</code></td><td>L 版本</td><td>COCO</td><td>500 epochs</td><td>YOLOv8 L 版本，适合高精度任务，计算资源需求较高。</td></tr><tr><td><code>yolov8_m_500e_coco.yml</code></td><td>M 版本</td><td>COCO</td><td>500 epochs</td><td>YOLOv8 M 版本，精度与速度平衡，适中任务。</td></tr><tr><td><code>yolov8_n_500e_coco.yml</code></td><td>N 版本</td><td>COCO</td><td>500 epochs</td><td>YOLOv8 N 版本，适合资源有限的环境，速度较快。</td></tr><tr><td><code>yolov8_s_500e_coco.yml</code></td><td>S 版本</td><td>COCO</td><td>500 epochs</td><td>YOLOv8 S 版本，适合较小任务，计算资源要求低。</td></tr><tr><td><code>yolov8_x_500e_coco.yml</code></td><td>X 版本</td><td>COCO</td><td>500 epochs</td><td>YOLOv8 X 版本，精度较高，适用于复杂任务。</td></tr><tr><td><code>yolov8p6_x_500e_coco.yml</code></td><td>X 版本（P6）</td><td>COCO</td><td>500 epochs</td><td>YOLOv8p6 X 版本，优化精度和性能，适合高精度应用。</td></tr></tbody></table><p>这些版本的区别主要在于模型大小、精度与计算资源需求的平衡，按照自己的需求选择即可，选哪个都可以运行，训练周期我们是可以控制的。</p><p>这里我需要配置<code>m</code>版本模型，为了防止破坏项目结构，新建一个文件放置我自己的配置文件，比如<code>yolov8_m_500e_coco_mydataset.yml</code>，内容如下：</p><figure class="highlight yaml"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">_BASE_:</span> [</span><br><span class="line">  <span class="string">'../datasets/coco_detection_mydataset.yml'</span>,</span><br><span class="line">  <span class="string">'../runtime.yml'</span>,</span><br><span class="line">  <span class="string">'_base_/optimizer_500e_high_mydataset.yml'</span>,</span><br><span class="line">  <span class="string">'_base_/yolov8_cspdarknet.yml'</span>,</span><br><span class="line">  <span class="string">'_base_/yolov8_reader_high_aug.yml'</span>,</span><br><span class="line">]</span><br><span class="line"><span class="attr">depth_mult:</span> <span class="number">0.67</span></span><br><span class="line"><span class="attr">width_mult:</span> <span class="number">0.75</span></span><br><span class="line"></span><br><span class="line"><span class="attr">log_iter:</span> <span class="number">50</span></span><br><span class="line"><span class="attr">snapshot_epoch:</span> <span class="number">5</span></span><br><span class="line"><span class="attr">weights:</span> <span class="string">output/yolov8_m_500e_coco/model_final</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="attr">YOLOv8CSPDarkNet:</span></span><br><span class="line">  <span class="attr">last_stage_ch:</span> <span class="number">768</span> <span class="comment"># The actual channel is int(768 * width_mult), not int(1024 * width_mult) as in YOLOv5</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="attr">TrainReader:</span></span><br><span class="line">  <span class="attr">batch_size:</span> <span class="number">8</span> <span class="comment"># default 8 gpus, total bs = 128</span></span><br></pre></td></tr></tbody></table></figure><p>在第一个<code>_BASE_</code>部分指定该配置文件引用了一些其他的配置，比如第一个是数据集配置文件，第二个为配置和管理模型训练或推理时的运行时环境参数配置文件，第三个为优化器配置文件，第四个为使用<code>CSPDarkNet</code>网络架构配置文件，第五个为数据加载起配置文件，这里我们只需要修改第一个和第三个，其余的如果熟练的话，可以按照自己的要求进行定制，第一个指向前面我们修改的数据集配置文件，第三个指定了一些学习率和学习率增量等一些配置。</p><p>我们先看上面的训练配置文件，其中配置作用如下：</p><ul><li><strong>depth_mult</strong>:<br>控制网络深度的缩放比例。<code>0.67</code> 表示将网络的层数减少到原来的 <code>67%</code>，从而减少模型的复杂度和计算量，但可能会影响模型的精度。</li><li><strong>width_mult</strong>:<br>控制网络宽度的缩放比例。<code>0.75</code> 表示将网络每层的通道数减少到原来的 <code>75%</code>，从而减少模型的参数量和计算复杂度，但可能也会影响性能。</li><li><strong>log_iter</strong>:<br>设置日志输出的频率。<code>50</code> 表示每经过50次训练迭代就记录一次日志信息。这有助于监控训练进度、损失变化和其他重要指标。</li><li><strong>snapshot_epoch</strong>:<br>设置模型保存的频率。<code>5</code> 表示每训练5个<code>epoch</code>保存一次模型，以便在训练过程中进行检查点保存，便于恢复或调优。</li><li><strong>weights</strong>:<br>指定预训练模型的路径，<code>output/yolov8_m_500e_coco/model_final</code> 指向预训练的权重文件。这些预训练权重有助于加速收敛，特别是在类似任务的微调过程中。</li><li><strong>YOLOv8CSPDarkNet:</strong><ul><li><strong>last_stage_ch</strong>:<br>设置<code>YOLOv8 CSPDarkNet</code>模型最后一层的通道数。<code>768</code> 是实际通道数（在应用了 <code>width_mult</code> 后是 <code>int(768 * 0.75) = 576</code>）。这个参数决定了特征提取网络的宽度，影响模型的复杂度和性能。</li></ul></li></ul><ul><li><strong>TrainReader</strong>:<ul><li><strong>batch_size</strong>:<br>设置每个 GPU 上的批处理大小。<code>8</code> 表示每个<code>GPU</code>在一次迭代中处理 8 个样本。如果使用多个<code>GPU</code>，总批处理大小会更大，当然如果算力有限，那就越小越好啦！</li></ul></li></ul><h3 id="优化器配置"><a href="#优化器配置" class="headerlink" title="优化器配置"></a>优化器配置</h3><p>这里其实没什么好说的，主要能修改的就是学习率和轮次了，这个都需要按照自己的项目需求进行修改，我这里就简单测试一下，后续会上算力机器进行训练，所以简单训练个50轮即可，该文件就是上面<code>_BASE_</code>配置中第三个配置文件。</p><figure class="highlight yaml"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># epoch: 50</span></span><br><span class="line"></span><br><span class="line"><span class="attr">LearningRate:</span></span><br><span class="line">  <span class="attr">base_lr:</span> <span class="number">0.005</span></span><br><span class="line">  <span class="attr">schedulers:</span></span><br><span class="line">  <span class="bullet">-</span> <span class="type">!YOLOv5LRDecay</span></span><br><span class="line">    <span class="attr">max_epochs:</span> <span class="number">500</span></span><br><span class="line">    <span class="attr">min_lr_ratio:</span> <span class="number">0.1</span> <span class="comment">#</span></span><br><span class="line">  <span class="bullet">-</span> <span class="type">!ExpWarmup</span></span><br><span class="line">    <span class="attr">epochs:</span> <span class="number">5</span> <span class="comment">#3</span></span><br><span class="line"></span><br><span class="line"><span class="attr">OptimizerBuilder:</span></span><br><span class="line">  <span class="attr">optimizer:</span></span><br><span class="line">    <span class="attr">type:</span> <span class="string">Momentum</span></span><br><span class="line">    <span class="attr">momentum:</span> <span class="number">0.937</span></span><br><span class="line">    <span class="attr">use_nesterov:</span> <span class="literal">True</span></span><br><span class="line">  <span class="attr">regularizer:</span></span><br><span class="line">    <span class="attr">factor:</span> <span class="number">0.0005</span></span><br><span class="line">    <span class="attr">type:</span> <span class="string">L2</span></span><br><span class="line">  <span class="attr">clip_grad_by_value:</span> <span class="number">10</span><span class="string">.</span></span><br></pre></td></tr></tbody></table></figure><p>到了目前，所有的配置基本结束，下面开始训练。</p><h2 id="训练和测试"><a href="#训练和测试" class="headerlink" title="训练和测试"></a>训练和测试</h2><p>这里其实就是一个命令的事情，所以我按照官网的说法，实现了一个<code>bat</code>文件，按照自己的要求进行注释和打开注释即可运行：</p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br></pre></td><td class="code"><pre><span class="line">@<span class="built_in">echo</span> off</span><br><span class="line">setlocal enabledelayedexpansion</span><br><span class="line"></span><br><span class="line">:: 设置模型名称和作业名称</span><br><span class="line"><span class="built_in">set</span> model_name=yolov8</span><br><span class="line"><span class="built_in">set</span> job_name=yolov8_m_500e_coco_mydataset</span><br><span class="line"></span><br><span class="line"><span class="built_in">set</span> config=configs\%model_name%\%job_name%.yml</span><br><span class="line"><span class="built_in">set</span> log_dir=log_dir\%job_name%</span><br><span class="line"><span class="built_in">set</span> weights=output\%job_name%\model_final.pdparams</span><br><span class="line"></span><br><span class="line">:: 1. 训练（单卡/多卡），加 --<span class="built_in">eval</span> 表示边训边评估，加 --amp 表示混合精度训练</span><br><span class="line"><span class="built_in">set</span> CUDA_VISIBLE_DEVICES=0</span><br><span class="line">python -m paddle.distributed.launch --log_dir=%log_dir% --gpus 0 tools/train.py -c %config% --<span class="built_in">eval</span> --amp  --use_vdl True --vdl_log_dir=vdl_dir/scalar -o pretrain_weights=./models/yolov8_m_500e_coco.pdparams</span><br><span class="line"></span><br><span class="line">:: 2. 评估，加 --classwise 表示输出每一类mAP</span><br><span class="line">:: python tools/eval.py -c %config% -o weights=%weights% --classwise</span><br><span class="line"></span><br><span class="line">:: 3. 预测（单张图/图片文件夹）</span><br><span class="line">python tools/infer.py -c %config% -o weights=%weights% --infer_img=./dataset/MyDataSet-coco/train/000002.jpg --draw_threshold=0.2</span><br><span class="line">:: python tools/infer.py -c %config% -o weights=%weights% --infer_dir=demo\ --draw_threshold=0.5</span><br><span class="line"></span><br><span class="line">:: 4. 导出模型，以下3种模式选一种</span><br><span class="line">:: 普通导出</span><br><span class="line">:: python tools/export_model.py -c %config% -o weights=%weights% </span><br><span class="line"></span><br><span class="line">:: exclude_post_process 去除后处理导出，返回和 YOLOv5 导出 ONNX 时相同格式的 concat 后的 1 个 Tensor</span><br><span class="line">:: python tools/export_model.py -c %config% -o weights=%weights% exclude_post_process=True </span><br><span class="line"></span><br><span class="line">:: exclude_nms 去除 NMS 导出，返回 2 个 Tensor</span><br><span class="line">:: python tools/export_model.py -c %config% -o weights=%weights% exclude_nms=True </span><br><span class="line"></span><br><span class="line">:: 5. 部署预测</span><br><span class="line">:: python deploy/python/infer.py --model_dir=output_inference\%job_name% --image_file=demo\000000014439_640x640.jpg --device=GPU</span><br><span class="line"></span><br><span class="line">:: 6. 部署测速，加 “--run_mode=trt_fp16” 表示在 TensorRT FP16 模式下测速</span><br><span class="line">:: python deploy/python/infer.py --model_dir=output_inference\%job_name% --image_file=demo\000000014439_640x640.jpg --device=GPU --run_benchmark=True </span><br><span class="line"></span><br><span class="line">:: 7. ONNX 导出</span><br><span class="line">:: paddle2onnx --model_dir output_inference\%job_name% --model_filename model.pdmodel --params_filename model.pdiparams --opset_version 12 --save_file %job_name%.onnx</span><br><span class="line"></span><br><span class="line">:: 8. ONNX TRT 测速</span><br><span class="line">:: <span class="string">"C:\Program Files\TensorRT-8.0.3.4\bin\trtexec.exe"</span> --onnx=%job_name%.onnx --workspace=4096 --avgRuns=10 --shapes=input:1x3x640x640 --fp16</span><br><span class="line">:: <span class="string">"C:\Program Files\TensorRT-8.0.3.4\bin\trtexec.exe"</span> --onnx=%job_name%.onnx --workspace=4096 --avgRuns=10 --shapes=input:1x3x640x640 --fp32</span><br><span class="line"></span><br><span class="line"><span class="built_in">echo</span> 完成！</span><br><span class="line">pause</span><br></pre></td></tr></tbody></table></figure><p>以上脚本包含训练和测试部署等所有命令，我仅测试了训练和测试，如果还有更高的要求请按照官方文档进行配置，最终的结果会在<code>/output</code>显示出来，可能图上的标注会和你的标注无法对应上，这是正产现象，因为<code>PaddleYOLO</code>将<code>coco</code>数据集标注字典内置了，目前我还没找到修改的地方，完全不影响，因为结果是标注ID，如果需要可视化自行实现一个即可。</p><h2 id="参考文章"><a href="#参考文章" class="headerlink" title="参考文章"></a>参考文章</h2><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzUyODg5MzE3L2FydGljbGUvZGV0YWlscy8xNDYwOTkwMTU" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2024/07/27/66a461b627dc2.webp)"></div><div class="tag-link-right"><div class="tag-link-title">基于SeaShips数据集的yolov8训练教程</div><div class="tag-link-sitename">blog.csdn.net@卧式纯绿</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly9jbG91ZC50ZW5jZW50LmNvbS9kZXZlbG9wZXIvYXJ0aWNsZS8yMzg0NjUw" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2025/04/08/67f4cf44d4d5e.webp)"></div><div class="tag-link-right"><div class="tag-link-title">基于YOLOv8的船舶目标检测系统（Python源码+Pyqt6界面+数据集）</div><div class="tag-link-sitename">cloud.tencent.com@AI小怪兽</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly9haXN0dWRpby5iYWlkdS5jb20vcHJvamVjdGRldGFpbC81NTU3MDY1" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2024/07/27/66a461e1ae5b5.webp)"></div><div class="tag-link-right"><div class="tag-link-title">PaddleYOLO：车牌检测yolov5</div><div class="tag-link-sitename">aistudio.baidu.com@DDDDB</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly9haS5iYWlkdS5jb20vc3VwcG9ydC9uZXdzP2FjdGlvbj1kZXRhaWwmaWQ9MTA5OQ" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2024/07/27/66a461e1ae5b5.webp)"></div><div class="tag-link-right"><div class="tag-link-title">快到没朋友的YOLO v3有了PaddlePaddle实现 | 代码+预训练模型</div><div class="tag-link-sitename">百度大脑 - AI开放平台</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL1BhZGRsZVBhZGRsZS9QYWRkbGVZT0xP" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2024/07/27/66a461a3098aa.webp)"></div><div class="tag-link-right"><div class="tag-link-title">YOLO series of PaddlePaddle implementation</div><div class="tag-link-sitename">github.com@PaddlePaddle</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><h2 id="声明"><a href="#声明" class="headerlink" title="声明"></a>声明</h2><ul><li>以上内容仅供学术研究和学习交流使用，如有侵权，请联系我进行删除处理。</li><li>若有任何问题或需要进一步讨论，请随时联系我的邮箱：<a href="mailto:01@liushen.fun">01@liushen.fun</a>。</li></ul><h2 id="每日一图"><a href="#每日一图" class="headerlink" title="每日一图"></a>每日一图</h2><p>图片来自<a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9oYW93YWxscGFwZXIuY29tL2hvbWVWaWV3TG9vay8xNjY3MjM4MjkwNTUzNTg3Mg">哲风壁纸</a></p><p><img src="" data-lazy-src="https://p.liiiu.cn/i/2025/04/08/67f4ca305082b.webp" alt="静谧教室"></p></article><div class="post-copyright"><div class="post-copyright__title"><span class="post-copyright-info"><h>PaddleYOLO训练自己的数据集</h></span></div><div class="post-copyright__type"><span class="post-copyright-info"><a href="https://blog.liushen.fun/posts/4bb33804/">https://blog.liushen.fun/posts/4bb33804/</a></span></div><div class="post-copyright-m"><div class="post-copyright-m-info" style="position:relative;z-index:3"><div class="post-copyright-a" style="display:inline-block;width:fit-content;margin:20px 20px 20px 0"><h>作者</h><div class="post-copyright-cc-info"><h>LiuShen</h></div></div><div class="post-copyright-c" style="display:inline-block;width:fit-content;margin:20px 20px 20px 0"><h>发布于</h><div class="post-copyright-cc-info"><h>2025-04-08</h></div></div><div class="post-copyright-u" style="display:inline-block;width:fit-content;margin:20px 20px 20px 0"><h>更新于</h><div class="post-copyright-cc-info"><h>2025-04-08</h></div></div><div class="post-copyright-c" style="display:inline-block;width:fit-content;margin:20px 20px 20px 0"><h>许可协议</h><div class="post-copyright-cc-info"><a rel="noopener" target="_blank" title=" CC BY 4.0" href="https://creativecommons.org/licenses/by-nc-sa/4.0/?ref=chooser-v1">CC BY-NC-SA 4.0</a></div></div></div></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/">学习笔记</a><a class="post-meta__tags" href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">机器学习</a><a class="post-meta__tags" href="/tags/%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/">神经网络</a></div><div class="post-share"><div class="social-share" data-image="https://p.liiiu.cn/i/2025/04/08/67f49876a62e5.webp" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://jsd.liiiu.cn/npm/butterfly-extsrc@1.1.4/sharejs/dist/css/share.min.css" media="print" onload='this.media="all"'><script src="https://jsd.liiiu.cn/npm/butterfly-extsrc@1.1.4/sharejs/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i>来😍鼠标过来一点~</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/config/img/wechat.png" target="_blank"><img class="post-qr-code-img" src="" data-lazy-src="/config/img/wechat.png" alt="微信"></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/config/img/wechat.png" target="_blank"><img class="post-qr-code-img" src="" data-lazy-src="/config/img/wechat.png" alt="支付宝"></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><a class="prev-post pull-left" href="/posts/4355f2b3/" title="Hexo配置SWPP实现PWA"><img class="cover" src="" data-lazy-src="https://p.liiiu.cn/i/2025/03/27/67e56a745e1cc.webp" onerror='onerror=null,src="/img/404.jpg"' alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Hexo配置SWPP实现PWA</div></div></a><a class="next-post pull-right" href="/posts/caee2d9f/" title="美化你的RSS订阅地址"><img class="cover" src="" data-lazy-src="https://p.liiiu.cn/i/2025/04/18/68024a618942b.webp" onerror='onerror=null,src="/img/404.jpg"' alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">美化你的RSS订阅地址</div></div></a></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><a href="/posts/57a50b33/" title="DCAMNet钢铁缺陷检测网络复现"><img class="cover" src="" data-lazy-src="https://p.liiiu.cn/i/2024/03/22/65fc5eceae5bd.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-02-01</div><div class="title">DCAMNet钢铁缺陷检测网络复现</div></div></a><a href="/posts/67189760/" title="Spikformer脉冲神经网络学习"><img class="cover" src="" data-lazy-src="https://p.liiiu.cn/i/2024/07/06/6688d4b63b50f.webp" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-07-06</div><div class="title">Spikformer脉冲神经网络学习</div></div></a><a href="/posts/2229c0f4/" title="CNN+transformer入门学习"><img class="cover" src="" data-lazy-src="https://pic2.zhimg.com/v2-e3b4212c09df05a0484da4eb5392a0d9_r.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-01-05</div><div class="title">CNN+transformer入门学习</div></div></a></div></div><hr class="custom-hr"><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i> <span>评论</span></div></div><div class="comment-wrap"><div><div id="artalk-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info is-center"><div class="author-info-detail"><p class="author-info-hello">👋 欢迎光临！</p><p class="author-info-desc">你们好呀！我是站长LiuShen！一个快乐，积极，热爱生活的孩纸！😜😜😜</p></div><div class="avatar-img"><img class="mood-icon" src="" data-lazy-src="https://p.liiiu.cn/i/2025/03/14/67d301461a24a.webp" alt="🤤" onerror='this.onerror=null,this.src="/img/friend_404.gif"'><img src="" data-lazy-src="https://p.liiiu.cn/i/2025/03/13/67d2fc82d329c.webp" onerror='this.onerror=null,this.src="/img/friend_404.gif"' alt="avatar"></div><div class="author-info-name">LiuShen</div><div class="site-data"><a href="/archives/"><div class="headline">文章</div><div class="length-num">72</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">98</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">3</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/willow-god"><i class="fab fa-github"></i><span>Follow Me 🛫</span></a><div class="card-info-social-icons"><a class="social-icon" href="mailto:01@liushen.fun" target="_blank" title="Email"><i class="fa-solid fa-envelope"></i></a><a class="social-icon" href="http://wpa.qq.com/msgrd?v=3&amp;uin=3162475700&amp;site=qq&amp;menu=yes" target="_blank" title="QQ：3162475700"><i class="fa-brands fa-qq"></i></a><a class="social-icon" href="https://wakatime.com/@LiuShen" target="_blank" title="Wakatime"><i class="fa-solid fa-chart-column"></i></a><a class="social-icon" href="https://blog.liushen.fun/atom.xml" target="_blank" title="rss地址"><i class="fa-solid fa-rss"></i></a></div></div><div class="card-widget" id="card-poem"><div id="poem_sentence"></div><div id="poem_info"><div id="poem_dynasty"></div><div id="poem_author"></div></div></div><script src="/js/jinrishici.js" charset="utf-8"></script><script>jinrishici.load((function(e){var n=document.querySelector("#poem_sentence"),t=document.querySelector("#poem_author"),o=document.querySelector("#poem_dynasty"),r=e.data.content;r=r.substr(0,r.length-1),n.innerHTML=r,o.innerHTML=e.data.origin.dynasty,t.innerHTML=e.data.origin.author+"《"+e.data.origin.title+"》"}))</script><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content"><p><strong>博客架构概览：</strong><br>⚙️框架核心：Hexo<br>🕹️界面设计：Butterfly<br>🔮安全保障：长亭雷池<br>🔩管理工具：宝塔面板，1Panel<br>🎰服务器支持：阿里云，腾讯云<br>🎲CDN加速：多吉云，CloudFlare<br><strong>快捷跳转地址：</strong><br>🧩个人相册：<a target="_blank" rel="noopener" href="https://xc.liushen.fun">xc.liushen.fun</a><br>🤖个人导航：<a target="_blank" rel="noopener" href="https://www.liushen.fun">www.liushen.fun</a><br></p><img src="" data-lazy-src="/config/img/notice.gif" alt="可爱捏" title="可爱捏" style="width:100%;border-radius:10px"></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%A2%8E%E7%A2%8E%E5%BF%B5"><span class="toc-text">碎碎念</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BB%8B%E7%BB%8D"><span class="toc-text">介绍</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%80%A7%E8%83%BD%E4%BC%98%E5%8A%BF"><span class="toc-text">性能优势</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%A8%A1%E5%9E%8B%E6%94%AF%E6%8C%81%E5%88%97%E8%A1%A8"><span class="toc-text">模型支持列表</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#MMYOLO%E5%AF%B9%E6%AF%94"><span class="toc-text">MMYOLO对比</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE"><span class="toc-text">环境配置</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Python"><span class="toc-text">Python</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#PaddlePaddle"><span class="toc-text">PaddlePaddle</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E9%A2%84%E5%A4%84%E7%90%86"><span class="toc-text">数据预处理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E6%A0%BC%E5%BC%8F"><span class="toc-text">数据格式</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E5%87%86%E5%A4%87"><span class="toc-text">数据准备</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%A0%BC%E5%BC%8F%E8%BD%AC%E6%8D%A2"><span class="toc-text">格式转换</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%B0%83%E6%95%B4%E9%85%8D%E7%BD%AE"><span class="toc-text">调整配置</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E5%BA%93%E9%85%8D%E7%BD%AE"><span class="toc-text">数据库配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%AD%E7%BB%83%E9%85%8D%E7%BD%AE"><span class="toc-text">训练配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BC%98%E5%8C%96%E5%99%A8%E9%85%8D%E7%BD%AE"><span class="toc-text">优化器配置</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AE%AD%E7%BB%83%E5%92%8C%E6%B5%8B%E8%AF%95"><span class="toc-text">训练和测试</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E8%80%83%E6%96%87%E7%AB%A0"><span class="toc-text">参考文章</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%A3%B0%E6%98%8E"><span class="toc-text">声明</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%AF%8F%E6%97%A5%E4%B8%80%E5%9B%BE"><span class="toc-text">每日一图</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/posts/7915ee6b/" title="数据库可视化WEB工具对比"><img src="" data-lazy-src="https://p.liiiu.cn/i/2025/05/25/6832cc105bc41.webp" onerror='this.onerror=null,this.src="/img/404.jpg"' alt="数据库可视化WEB工具对比"></a><div class="content"><a class="title" href="/posts/7915ee6b/" title="数据库可视化WEB工具对比">数据库可视化WEB工具对比</a><time datetime="2025-05-25T10:01:21.000Z" title="更新于 2025-05-25 18:01:21">2025-05-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/40702a0d/" title="本地实现HEXO文章AI摘要"><img src="" data-lazy-src="https://p.liiiu.cn/i/2025/05/06/6819cd4532457.webp" onerror='this.onerror=null,this.src="/img/404.jpg"' alt="本地实现HEXO文章AI摘要"></a><div class="content"><a class="title" href="/posts/40702a0d/" title="本地实现HEXO文章AI摘要">本地实现HEXO文章AI摘要</a><time datetime="2025-05-06T16:01:21.000Z" title="更新于 2025-05-07 00:01:21">2025-05-07</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/5f71a4b1/" title="耗子面板和DPanel简单体验"><img src="" data-lazy-src="https://p.liiiu.cn/i/2025/04/27/680dc7916ef34.webp" onerror='this.onerror=null,this.src="/img/404.jpg"' alt="耗子面板和DPanel简单体验"></a><div class="content"><a class="title" href="/posts/5f71a4b1/" title="耗子面板和DPanel简单体验">耗子面板和DPanel简单体验</a><time datetime="2025-04-28T14:48:21.000Z" title="更新于 2025-04-28 22:48:21">2025-04-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/caee2d9f/" title="美化你的RSS订阅地址"><img src="" data-lazy-src="https://p.liiiu.cn/i/2025/04/18/68024a618942b.webp" onerror='this.onerror=null,this.src="/img/404.jpg"' alt="美化你的RSS订阅地址"></a><div class="content"><a class="title" href="/posts/caee2d9f/" title="美化你的RSS订阅地址">美化你的RSS订阅地址</a><time datetime="2025-04-18T12:48:21.000Z" title="更新于 2025-04-18 20:48:21">2025-04-18</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap" style="background:0 0"><div id="footer_icons"><div><a class="icon_link" rel="noopener external nofollow" href="https://www.liushen.fun/" title="导航站点" target="_blank"><i class="fa-solid fa-compass"></i></a><a class="icon_link" rel="noopener external nofollow" href="https://admin.qidian.qq.com/static_proxy/b2b-qq/wpa-link/index.html#/person?uin=3162475700" title="联系QQ" target="_blank"><i class="fa-brands fa-qq"></i></a><a class="icon_link" rel="noopener external nofollow" href="https://github.com/willow-god" title="我的github主页" target="_blank"><i class="fa-brands fa-github"></i></a><a class="icon_link" rel="noopener external nofollow" href="mailto:01@liushen.fun" title="发送邮件至博主邮箱" target="_blank"><i class="fa-solid fa-envelope"></i></a></div><div class="footer_logo_container" onclick="btf.scrollToDest(0,500)" title="返回顶部"><img class="footer_logo" src="" data-lazy-src="/img/footer.gif"></div><div><a class="icon_link" rel="noopener external nofollow" href="https://wakatime.com/@LiuShen" title="Wikitime" target="_blank"><i class="fa-solid fa-clock"></i></a><a class="icon_link" rel="noopener external nofollow" href="https://gitlab.com/" title="gitlab" target="_blank"><i class="fa-brands fa-gitlab"></i></a><a class="icon_link" href="/shuoshuo/" title="日常说说" data-pjax-state="data-pjax-state"><i class="fa-solid fa-file-pen"></i></a><a class="icon_link" href="/comment/" title="留言板" data-pjax-state="data-pjax-state"><i class="fa-solid fa-comment"></i></a></div></div><div id="footer_content"><div class="footer-group"><h3 class="footer-title">关于本站</h3><div class="footer-links"><a class="footer-item" target="_blank" href="https://www.liushen.fun/">导航站点</a><a class="footer-item" href="/shuoshuo/">日常说说</a><a class="footer-item" target="_blank" href="https://um.liushen.fun/share/bIEnQp0xnMxD8c9V/blog.liushen.fun">访客信息</a><a class="footer-item" target="_blank" href="https://mm.liushen.fun/">提笔摘星</a><a class="footer-item" target="_blank" href="https://status.liushen.fun/">在线状态</a><a class="footer-item" href="/subscribe/">订阅本站</a></div></div><div class="footer-group"><h3 class="footer-title">加入组织</h3><div class="footer-links"><a class="footer-item" target="_blank" href="https://www.boyouquan.com/home">博友圈</a><a class="footer-item" target="_blank" href="https://github.com/timqian/chinese-independent-blogs">中博列表</a><a class="footer-item" target="_blank" href="https://blogwe.com/">博客我们</a><a class="footer-item" target="_blank" href="https://storeweb.cn/">个性商店</a><a class="footer-item" target="_blank" href="https://bf.zzxworld.com/">发现博客</a><a class="footer-item" target="_blank" href="https://ourblo.gs/">OurBlogs</a></div></div><div class="footer-group"><h3 class="footer-title">文章整理</h3><div class="footer-links"><a class="footer-item" href="/categories/website/">博客管理</a><a class="footer-item" href="/categories/learning/">学习资料</a><a class="footer-item" href="/categories/daily-share/">日常分享</a><a class="footer-item" href="/archives/">时光卷轴</a><a class="footer-item" href="/charts/">文章通览</a><a class="footer-item" href="/categories/">查看全部</a></div></div><div class="footer-group"><h3 class="footer-title">文章标签</h3><div class="footer-links"><a class="footer-item" href="/tags/JavaScript/">JS知识</a><a class="footer-item" href="/tags/Hexo/">本站框架</a><a class="footer-item" href="/tags/机器学习/">机器学习</a><a class="footer-item" href="/tags/日记/">个人日记</a><a class="footer-item" href="/tags/CSS/">CSS知识</a><a class="footer-item" href="/tags/">查看全部</a></div></div><div class="footer-group"><h3 class="footer-title">自建工具</h3><div class="footer-links"><a class="footer-item" target="_blank" rel="noopener" href="https://chat.liushen.fun/">清羽AI</a><a class="footer-item" target="_blank" rel="noopener" href="https://hot.liushen.fun/">今日热榜</a><a class="footer-item" target="_blank" rel="noopener" href="https://cover.qyliu.top/">封面设计</a><a class="footer-item" target="_blank" rel="noopener" href="https://icon.qyliu.top/">万变图标</a><a class="footer-item" target="_blank" rel="noopener" href="https://tmail.qyliu.top/">临时邮箱</a><a class="footer-item" target="_blank" rel="noopener" href="https://share.liushen.fun/">内容中转</a></div></div><div class="footer-group" id="friend-links-in-footer"><h3 class="footer-title">友链<button title="换一批" href="javascript:;" onclick="liushen.randomLink()"><i class="fa-solid fa-rotate-right"></i></button></h3><div class="footer-links"><a class="footer-item" target="_blank" href="https://blog.liushen.fun">测试1</a><a class="footer-item" target="_blank" href="https://blog.liushen.fun">测试2</a><a class="footer-item" target="_blank" href="https://blog.liushen.fun">测试3</a><a class="footer-item" target="_blank" href="https://blog.liushen.fun">测试4</a><a class="footer-item" target="_blank" href="https://blog.liushen.fun">测试5</a><a class="footer-item" href="/link/" data-pjax-state="data-pjax-state">查看更多</a></div></div></div><div id="footer-bottom"><div class="footer-bottom-content"><div class="footer-bottom-left"><span class="copyright">©2021 - 2025 By <a target="_blank" rel="noopener" href="https://blog.liushen.fun/about/" title="点击访问&quot;LiuShen&quot;的主页" style="margin-left:5px">LiuShen</a></span><div><a class="footer-bottom-link" target="_blank" href="https://beian.miit.gov.cn/" rel="noopener external nofollow" title="工信部备案号">陕ICP备2024028531号-2</a><a class="footer-bottom-link" target="_blank" href="https://beian.mps.gov.cn/#/query/webSearch?code=61011602000637" rel="noopener external nofollow" title="公安备案号">陕公网安备61011602000637号</a></div></div><div class="footer-bottom-right"><div id="runtime" title="本站运行时间">本站已苟活：0 天 0 时 0 分 0 秒</div><div><a class="footer-bottom-link" target="_blank" href="https://www.dogecloud.com/?iuid=9173" rel="noopener external nofollow" title="本站通过多吉云CDN提供站点加速">多吉云CDN</a><a class="footer-bottom-link" target="_blank" href="https://hexo.io/zh-cn/" rel="noopener external nofollow" title="本站使用Hexo架构搭建而成">Hexo静态框架</a><a class="footer-bottom-link" target="_blank" href="https://butterfly.js.org/" rel="noopener external nofollow" title="本站主题由Butterfly主题魔改而成">LiuShen主题</a></div></div></div></div></div><script>window.liushen||(window.liushen={saveData:(e,n)=>{localStorage.setItem(e,JSON.stringify({time:Date.now(),data:n}))},loadData:(e,n)=>{let t=JSON.parse(localStorage.getItem(e));if(t){let e=Date.now()-t.time;if(e>=0&&e<6e4*n)return t.data}return null},runtime:()=>{const e=e=>e>9?e:"0"+e,n=new Date("2021/12/12 01:27:36").getTime(),t=Date.now();let i=Math.round((t-n)/1e3),o="本站已苟活：";i>=86400&&(o+=`${e(Math.floor(i/86400))} 天 `,i%=86400),i>=3600&&(o+=`${e(Math.floor(i/3600))} 时 `,i%=3600),i>=60&&(o+=`${e(Math.floor(i/60))} 分 `,i%=60),o+=`${e(i)} 秒`;const l=document.getElementById("runtime");l&&(l.innerHTML=o),setTimeout(window.liushen.runtime,1e3)},randomLink:()=>{let e=window.liushen.loadData("links",30);if(e){let n=document.querySelectorAll("#friend-links-in-footer .footer-item");if(!n.length)return;for(let t=0;t<n.length;t++){let i=Math.floor(Math.random()*e.length);n[t].innerText=e[i].name,n[t].href=e[i].link,e.splice(i,1)}}else fetch("/flink_count.json").then((e=>e.json())).then((e=>{window.liushen.saveData("links",e.link_list),window.liushen.randomLink()}))}}),window.liushen.randomLink(),document.addEventListener("DOMContentLoaded",window.liushen.randomLink),window.liushen.runtime()</script></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="translateLink" type="button" title="简繁转换" style="width:35px">繁</button><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i><span class="rightside-text">阅读模式</span></button><button id="darkmode" type="button" title="日间和夜间模式切换"><i class="fa-regular fa-star-half-stroke"></i><span class="rightside-text">亮暗切换</span></button><button id="cat" onclick="toggleLive2dVisibility()" title="小猫显隐"><i class="fa-solid fa-cat"></i><span class="rightside-text">小猫显隐</span></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fa-solid fa-arrows-left-right-to-line"></i><span class="rightside-text">侧栏显隐</span></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i><span class="rightside-text">更多设置</span></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i><span class="rightside-text">显示目录</span></button><button id="fullscreen" onclick="toggleFullScreen()" title="全屏切换"><i class="fa-solid fa-expand"></i><span class="rightside-text">全屏切换</span></button><a id="to_comment" href="#post-comment" title="前往评论"><i class="fas fa-comments"></i><span class="rightside-text">快速评论</span></a><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i><span class="rightside-text">回到顶部</span></button></div></div><div id="rightMenu"><div class="rightMenu-group rightMenu-small"><div class="rightMenu-item" id="menu-backward"><i class="fa-solid fa-arrow-left"></i></div><div class="rightMenu-item" id="menu-forward"><i class="fa-solid fa-arrow-right"></i></div><div class="rightMenu-item" id="menu-refresh"><i class="fa-solid fa-arrow-rotate-right"></i></div><div class="rightMenu-item" id="menu-home"><i class="fa-solid fa-house"></i></div></div><div class="rightMenu-group rightMenu-line hide" id="menu-text"><a class="rightMenu-item" id="copy" href="javascript:rm.copySelect();"><i class="fa-solid fa-copy"></i><span>复制选中文字</span></a><a class="rightMenu-item" id="reply" href="javascript:rm.replySelect();"><i class="fa-regular fa-comment"></i><span>评论选中段落</span></a></div><div class="rightMenu-group rightMenu-line rightMenuOther"><a class="rightMenu-item menu-link" href="/archives/"><i class="fa-solid fa-archive"></i><span>文章时间线</span></a><a class="rightMenu-item menu-link" href="/categories/"><i class="fa-solid fa-folder-open"></i><span>文章分大类</span></a><a class="rightMenu-item menu-link" href="/tags/"><i class="fa-solid fa-tags"></i><span>文章小标签</span></a></div><div class="rightMenu-group rightMenu-line rightMenuNormal"><a class="rightMenu-item menu-link" id="menu-radompage" href="/comment/"><i class="fa-solid fa-shoe-prints"></i><span>随心留言板</span></a><div class="rightMenu-item" id="menu-translate"><i class="fa-solid fa-earth-asia"></i><span>繁简模式切换</span></div><div class="rightMenu-item" id="menu-live2dvisibility"><i class="fa-solid fa-cat"></i><span>小猫显示隐藏</span></div><div class="rightMenu-item" id="menu-print"><i class="fa-solid fa-print fa-fw"></i><span>打印整个页面</span></div><a class="rightMenu-item menu-link" id="statement" href="/statement/"><i class="fa-regular fa-copyright fa-fw"></i><span>网站声明</span></a></div></div><div id="rightmenu-mask"></div><div><script src="/js/others.js?v=5.0.0"></script><script src="/js/utils.js?v=5.0.0"></script><script src="/js/main.js?v=5.0.0"></script><script src="https://jsd.liiiu.cn/npm/echarts@5.5.1/dist/echarts.simple.min.js"></script><script src="/js/rightmenu.js?v=5.0.0"></script><script src="/js/jinrishici.js"></script><script src="/js/tw_cn.js?v=5.0.0"></script><script src="https://jsd.liiiu.cn/npm/@fancyapps/ui@5.0.36/dist/fancybox/fancybox.umd.min.js"></script><script src="https://jsd.liiiu.cn/npm/instant.page@5.2.0/instantpage.min.js" type="module"></script><script src="https://jsd.liiiu.cn/npm/vanilla-lazyload@19.1.3/dist/lazyload.iife.min.js"></script><div class="js-pjax"><script>(()=>{let t=null;const e=null,o="shuoshuo"===GLOBAL_CONFIG_SITE.pageType,a=()=>{t&&(t.destroy(),t=null)},n=e=>t&&t.setDarkMode("dark"===e),l=(l=document,i=location.pathname)=>{t=Artalk.init({el:l.querySelector("#artalk-wrap"),server:"https://atk.liushen.fun",site:"清羽飞扬",darkMode:"dark"===document.documentElement.getAttribute("data-theme"),...e,pageKey:i,imgUploader:function(t){let e="Bearer 28|q18njD3pLtHiFy9WidqQrREwqZzb8Zionr8WzilI",o="https://www.baiwulin.work/api/v1/upload",a=new Headers;a.set("Accept","application/json"),a.set("Authorization",e);let n=new FormData;n.append("file",t);const l=(t,e,o)=>fetch(t,{method:"POST",body:e,headers:o}).then((t=>t.json())).then((t=>t.data.links.url)).catch((t=>(console.error("Image upload failed:",t),null)));return l(o,n,a).then((t=>t||(console.warn("雾林图床接口失败，尝试替换为秋叶图床"),e="Bearer 11|lsReISlSS0dyhDzt35ovtfYefGbWSRW2vvntPXs7",o="https://imgse.koxiuqiu.cc/api/v1/upload",a.set("Authorization",e),l(o,n,a))))}}),"null"!==GLOBAL_CONFIG.lightbox&&(t.on("list-loaded",(()=>{t.ctx.get("list").getCommentNodes().forEach((t=>{const e=t.getRender().$content;btf.loadLightbox(e.querySelectorAll("img:not([atk-emoticon])"))}))})),o&&(window.shuoshuoComment.destroyArtalk=()=>{a(),l.children.length&&(l.innerHTML="",l.classList.add("no-comment"))}),btf.addGlobalFn("pjaxSendOnce",a,"destroyArtalk"),btf.addGlobalFn("themeChange",n,"artalk"))},i=async(t,e)=>{"object"==typeof Artalk||(await btf.getCSS("https://jsd.liiiu.cn/npm/artalk@2.9.1/dist/Artalk.min.css"),await btf.getScript("https://jsd.liiiu.cn/npm/artalk@2.9.1/dist/Artalk.min.js")),l(t,e)};o?window.shuoshuoComment={loadComment:i}:setTimeout(i,0)})()</script></div><script>window.newestComments={changeContent:e=>(""===e||(e=(e=(e=(e=(e=e.replace(/<img.*?src="(.*?)"?[^\>]+>/gi,"[图片]")).replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,"[链接]")).replace(/<pre><code>.*?<\/pre>/gi,"[代码]")).replace(/<code>.*?<\/code>/gi,"[代码]")).replace(/<[^>]+>/g,"")).length>150&&(e=e.substring(0,150)+"..."),e),generateHtml:(e,t)=>{let n="";if(e.length)for(let t=0;t<e.length;t++){if(n+='<div class="aside-list-item">',e[t].avatar){const a="data-lazy-src";n+=`<a href="${e[t].url}" class="thumbnail"><img ${a}="${e[t].avatar}" alt="${e[t].nick}"></a>`}n+=`<div class="content">\n        <a class="comment" href="${e[t].url}" title="${e[t].content}">${e[t].content}</a>\n        <div class="name"><span>${e[t].nick} / </span><time datetime="${e[t].date}">${btf.diffDate(e[t].date,!0)}</time></div>\n        </div></div>`}else n+="暂无评论";t.innerHTML=n,window.lazyLoadInstance&&window.lazyLoadInstance.update(),window.pjax&&window.pjax.refresh(t)},newestCommentInit:(e,t)=>{const n=document.querySelector("#card-newest-comments .aside-list");if(n){const a=btf.saveToLocal.get(e);a?newestComments.generateHtml(JSON.parse(a),n):t(n)}},run:(e,t)=>{newestComments.newestCommentInit(e,t),btf.addGlobalFn("pjaxComplete",(()=>newestComments.newestCommentInit(e,t)),e)}}</script><script>window.addEventListener("load",(()=>{const t="artalk-newest-comments",{changeContent:a,generateHtml:e,run:n}=window.newestComments,r=new URLSearchParams({site_name:"清羽飞扬",limit:"5"});n(t,(async n=>{try{const s=await fetch(`https://atk.liushen.fun/api/v2/stats/latest_comments?${r}`),o=await s.json(),{avatarCdn:c,avatarDefault:i}=await(async()=>{const t=t=>t.startsWith("d=")?t:`d=${t}`;try{const a=await fetch("https://atk.liushen.fun/api/v2/conf"),e=await a.json(),{mirror:n,params:r,default:s}=e.frontend_conf.gravatar;return{avatarCdn:n,avatarDefault:t(r||s)}}catch(a){return console.error(a),{avatarCdn:"",avatarDefault:t("")}}})(),l=o.data.map((t=>({avatar:c&&t.email_encrypted?`${c}${t.email_encrypted}?${i}`:"",content:a(t.content_marked),nick:t.nick,url:t.page_url,date:t.date})));btf.saveToLocal.set(t,JSON.stringify(l),10/1440),e(l,n)}catch(t){console.log(t),n.textContent="无法获取评论，请确认相关配置是否正确"}}))}))</script><script src="/config/memos/memos.js"></script><script id="canvas_nest" defer color="128,128,128" opacity="0.7" zindex="-1" count="99" mobile="false" src="https://jsd.liiiu.cn/npm/butterfly-extsrc@1.1.4/dist/canvas-nest.min.js"></script><link rel="stylesheet" href="https://jsd.liiiu.cn/npm/aplayer@1.10.1/dist/APlayer.min.css" media="print" onload='this.media="all"'><script src="https://jsd.liiiu.cn/npm/aplayer@1.10.1/dist/APlayer.min.js"></script><script src="https://jsd.liiiu.cn/npm/meting@2.0.1/dist/Meting.min.js"></script><script src="https://jsd.liiiu.cn/npm/pjax@0.2.8/pjax.min.js"></script><script>(()=>{window.pjax=new Pjax({elements:'a:not([target="_blank"])',selectors:["head > title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show",".js-pjax"],cacheBust:!1,analytics:!1,scrollRestoration:!1});const e=e=>{e&&Object.values(e).forEach((e=>e()))};document.addEventListener("pjax:send",(()=>{btf.removeGlobalFnEvent("pjaxSendOnce"),btf.removeGlobalFnEvent("themeChange");const t=document.body.classList;t.contains("read-mode")&&t.remove("read-mode"),e(window.globalFn.pjaxSend)})),document.addEventListener("pjax:complete",(()=>{btf.removeGlobalFnEvent("pjaxCompleteOnce"),document.querySelectorAll("script[data-pjax]").forEach((e=>{const t=document.createElement("script"),n=e.text||e.textContent||e.innerHTML||"";Array.from(e.attributes).forEach((e=>t.setAttribute(e.name,e.value))),t.appendChild(document.createTextNode(n)),e.parentNode.replaceChild(t,e)})),e(window.globalFn.pjaxComplete)})),document.addEventListener("pjax:error",(e=>{404===e.request.status&&pjax.loadUrl("/404")}))})()</script><script async data-pjax="" src="/config/busuanzi/busuanzi.js"></script><div id="algolia-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="search-wrap"><div id="algolia-search-input"></div><hr><div id="algolia-search-results"><div id="algolia-hits"></div><div id="algolia-pagination"></div><div id="algolia-info"><div class="algolia-stats"></div><div class="algolia-poweredBy"></div></div></div></div></div><div id="search-mask"></div><script src="https://jsd.liiiu.cn/npm/algoliasearch@5.8.1/dist/lite/builds/browser.umd.min.js"></script><script src="https://jsd.liiiu.cn/npm/instantsearch.js@4.75.0/dist/instantsearch.production.min.js"></script><script src="/js/search/algolia.js?v=5.0.0"></script></div></div><div class="needEndHide" id="nav-music"><div id="nav-music-hoverTips" onclick="liuMusic.musicToggle()">音乐已暂停</div><meting-js id="13597135963" server="netease" type="playlist" mutex="true" preload="none" data-lrctype="0" order="random" volume="0.8" api="https://met.liiiu.cn/meting/api?server=:server&amp;type=:type&amp;id=:id&amp;r=:r"></meting-js></div><script data-pjax="">function butterfly_swiper_injector_config(){var a=document.getElementById("recent-posts");console.log("已挂载butterfly_swiper"),a.insertAdjacentHTML("afterbegin",'<div class="recent-post-item" style="height: auto;width: 100%"><div class="blog-slider swiper-container-fade swiper-container-horizontal" id="swiper_container"><div class="blog-slider__wrp swiper-wrapper" style="transition-duration: 0ms;"><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/4bb33804/&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://p.liiiu.cn/i/2025/04/08/67f49876a62e5.webp" alt="" onerror="this.src=/img/error-page.png; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2025-04-08</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/4bb33804/&quot;);" href="javascript:void(0);" alt="">PaddleYOLO训练自己的数据集</a><div class="blog-slider__text">近期一直在研究毕业设计，在其中，我涉及到了PaddleYOLO的训练和部署，在网上的教程较少，经过不断努力，我也算是跑出来了，所以在这里分享出来做个记录，防止下次使用又忘记了怎么搞。</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/4bb33804/&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/5f71a4b1/&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://p.liiiu.cn/i/2025/04/27/680dc7916ef34.webp" alt="" onerror="this.src=/img/error-page.png; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2025-04-28</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/5f71a4b1/&quot;);" href="javascript:void(0);" alt="">耗子面板和DPanel简单体验</a><div class="blog-slider__text">最近毕业设计临近尾声，代码也敲完了，目前就剩稍微的调优，就可以开始写论文啦！在闲暇时间，我也尝试部署了一些不一样的面板程序，总感觉1panel稍微有些复杂，很多功能并用不上，比如GPU，下面简单分享一下我的体验。</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/5f71a4b1/&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/40702a0d/&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://p.liiiu.cn/i/2025/05/06/6819cd4532457.webp" alt="" onerror="this.src=/img/error-page.png; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2025-05-07</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/40702a0d/&quot;);" href="javascript:void(0);" alt="">本地实现HEXO文章AI摘要</a><div class="blog-slider__text">五一假期结束啦！这五天啥也没干，就在宿舍敲代码，都快无聊死了，恰逢找到了一些免费API，就自己实现一个AI摘要吧！利用API生成摘要文本放在文章头部，再通过hexo进行渲染就好啦！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/40702a0d/&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/7915ee6b/&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://p.liiiu.cn/i/2025/05/25/6832cc105bc41.webp" alt="" onerror="this.src=/img/error-page.png; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2025-05-25</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/7915ee6b/&quot;);" href="javascript:void(0);" alt="">数据库可视化WEB工具对比</a><div class="blog-slider__text">最近迁移服务器，并且搞了一个1P专业版玩玩，感觉效果很不错，想找一个管理数据库的服务，其中看了phpmyadmin等一些知名项目，但是都不太符合我的要求，最后经过筛选，找到了比较合适的，分享给大家！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/7915ee6b/&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/caee2d9f/&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://p.liiiu.cn/i/2025/04/18/68024a618942b.webp" alt="" onerror="this.src=/img/error-page.png; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2025-04-18</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/caee2d9f/&quot;);" href="javascript:void(0);" alt="">美化你的RSS订阅地址</a><div class="blog-slider__text">近期天天忙着毕业设计，冷落了站点文章的更新，最近也终于算是快要搞完了，于是开始捣鼓一些好玩的东西，在浏览阮一峰大佬的周刊时，了解到了RSS也能美化，折腾了一下，没想到还真实现了，在此分享一下。</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/caee2d9f/&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div></div><div class="blog-slider__pagination swiper-pagination-clickable swiper-pagination-bullets"></div></div></div>')}for(var elist="null".split(","),cpage=location.pathname,epage="/",flag=0,i=0;i<elist.length;i++)cpage.includes(elist[i])&&flag++;("all"===epage&&0==flag||epage===cpage)&&butterfly_swiper_injector_config()</script><script defer src="https://jsd.liiiu.cn/npm/swiper@11.1.14/swiper-bundle.min.js"></script><script defer data-pjax="" src="/config/swiper/swiper_init.js"></script><script src="https://jsd.liiiu.cn/npm/live2d-widget@^3.1.3/lib/L2Dwidget.min.js"></script><script>L2Dwidget.init({pluginModelPath:"assets/",model:{scale:1,hHeadPos:.5,vHeadPos:.618,jsonPath:"/live2dw/assets/tororo.model.json"},display:{superSample:2,width:250,height:500,position:"left",hOffset:-20,vOffset:-90},mobile:{show:!1,scale:.5},react:{opacityDefault:.7,opacityOnHover:.2},log:!1,pluginJsPath:"lib/",pluginRootPath:"live2dw/",tagMode:!1})</script></body></html>